2010-10-20 48 views
2

我不知道为什么我得到这个错误。我也从下面的代码中得到一个EXC_BAD_ACCESS问题。任何想法为什么?l [20] ve:无效块类型?

didRecieveResponsedidRecieveDatadidRecieveDatadidFinishLoading上运行断点显示了前两个get run和mid way通过接收数据程序崩溃。

- (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 

    NSLog(@"%@",mellowListings); 

    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]; 
     counter++; 
    } 
} 

回答

0
plistContentsData = [NSMutableData data]; 

您创建一个自动释放NSMutableData对象,并有可能成为你退出didReceiveResponse方法无效后的权利。您需要保留plistContentsData来解决该错误。

+0

啊,那有效。 :)谢谢,恩,但仍然得到'无效块类型'错误。 :(有什么想法吗? – 2010-10-20 11:31:11

+0

在什么行(或方法)你会得到那个错误? – Vladimir 2010-10-20 11:32:56

+0

我不知道 - 在错误中不会出现断点。:/ – 2010-10-20 13:18:22