内存管理问题与connectionDidFinishLoading中的副本有关

时间:2012-10-24 07:15:42

标签: iphone memory-management

我通过此委托方法使用委托从一个类到另一个类传递_ndultArray对象在connectionDidFinishLoading中。我在dealloc中释放但我不确定它是否正常。如何释放这个_resultArray ..

这是我的代码..

-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
    NSString *urlDataString = [[NSString alloc]initWithData:receiveData 
        encoding:NSUTF8StringEncoding];
    NSMutableDictionary *soapDictionary = nil;
    soapDictionary = [parser objectWithString:urlDataString error:&error];
    resultArray = [soapDictionary copy];
    [urlDataString release];
    [self soapResultSurvey:resultArray];
}

//Delegate Method
-(void)soapResultSurvey:(id)_resultSurvey{
    [delegate soapResultSurvey:_resultSurvey];
}

1 个答案:

答案 0 :(得分:0)

resultArray = [[soapDictionary copy] autorelease];

然后记住resultArray将在稍后的线程结束时被释放,所以如果你的委托需要保留它,那么,在你的委托中执行soapResultSurvey:method