2010-10-20 66 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