2012-03-30 16 views
1

私はJSONConnectionオブジェクトを次のように使用しています。JSONConnectionオブジェクトを解放する方法

- (void)startGettingSearchResultsByKeyword:(NSString *)keyword 
           delegate:(id <DataProviderDelegate>)delegate 
{ 

    /* Prepare request */ 
    JSONConnection *jsonConnection = [[JSONConnection alloc] initWithURLString:NSLocalizedString(@"GET_SEARCH_RESULTS", nil)]; 

    [jsonConnection.requestValues setObject:APP_VERSION_VALUE forKey:APP_VERSION_KEY]; 
    [jsonConnection.requestValues setObject:keyword forKey:KEYWORD_KEY]; 

    /* Send asynchronnous URL request and process response */ 
    [jsonConnection sendAsynchronousRequestWithCompletionHandler:^(NSDictionary *responseValues, NSError *error) { 

     NSArray *responseDataArray = [[responseValues objectForKey:JSON_RESPONSE_DICTIONARY_KEY] JSONValue]; 

     NSMutableArray *searchResults = [[NSMutableArray alloc] init]; 

     if ([responseDataArray count] > 0) { 
      for (int index = 0; index < [responseDataArray count]; index++) { 
      NSDictionary *result = [responseDataArray objectAtIndex:index]; 

       ProductDetails *searchResult = [[ProductDetails alloc] init]; 

       NSNumber *contentId = [result objectForKey:NSLocalizedString(@"CONTENT_ID", nil)]; 

       searchResult.contentId = [NSString stringWithFormat:@"%d", [contentId intValue]];    
       searchResult.productName = [result objectForKey:NSLocalizedString(@"NAME", nil)]; 

       [searchResults addObject:searchResult]; 
       [searchResult release]; 
      } 
     } 

     [delegate didFinishGettingSearchResults:searchResults]; 

     [searchResults release]; 

    }]; 
} 

私は私のJSONConnectionオブジェクトをreleaseする正しい場所については考えています。

助けてください。

答えて

1

割り当て時にJSONConnectionを自動リリースしようとしましたか?

JSONConnection *jsonConnection = [[[JSONConnection alloc] initWithURLString:NSLocalizedString(@"GET_SEARCH_RESULTS", nil)] autorelease]; 
+0

Nop。私はなかった。だから、私はautoreleaseを追加し、それは正常に動作しています。ありがとう。 – chinthakad

関連する問題