iphone – l[20]ve: invalid chunk type? – Education Career Blog

I don’t know why I’m getting this error. I’m also getting an EXC_BAD_ACCESS issue from the following code. Any ideas why?

Running breakpoints on the didRecieveResponse and didRecieveData and didFinishLoading shows the first two get run and mid way through recieving data the program crashes.

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    // starts... :)
    plistContentsData = NSMutableData data; //NSMutableData - inst in head


- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    plistContentsData appendData:data;

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    mellowListings = NSArray alloc initWithData:plistContentsData; //NSArray - inst in head


    CLLocationCoordinate2D newLocation;

    int counter = 0;

    for(NSDictionary *tempDict in mellowListings){
        NSLog(@"%f",(tempDict objectForKey:@"lat" floatValue));
        NSLog(@"%f",(tempDict objectForKey:@"long" floatValue));
        newLocation.latitude = (tempDict objectForKey:@"lat" floatValue);
        newLocation.longitude = (tempDict objectForKey:@"long" floatValue);
        TCPlaceMarker *placemark = TCPlaceMarker alloc initWithCoordinate:newLocation;
        placemark.title = tempDict objectForKey:@"name";
        placemark.subtitle = tempDict objectForKey:@"address1";
        placemark.source = tempDict objectForKey:@"source" lowercaseString;
        placemark.tag = counter;
        mapView addAnnotation:placemark;


plistContentsData = NSMutableData data;

You create an autoreleased NSMutableData object and it may become invalid right after you exit didReceiveResponse method. You need to retain plistContentsData to fix that error.

Leave a Comment