xcode 4.3.3 iphone - 以后未引用的对象泄漏分配的对象

时间:2012-06-20 18:27:42

标签: ios xcode

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    self.listFeedConnection = nil;   // release our connection

    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;   

    // create the queue to run our ParseOperation
    self.queue = [[NSOperationQueue alloc] init];

    // create an ParseOperation (NSOperation subclass) to parse the RSS feed data so that the UI is not blocked
    // "ownership of mediaListData has been transferred to the parse operation and should no longer be
    // referenced in this thread.
    //
    ParseOperation *parser = [[ParseOperation alloc] initWithData:listData delegate:self];

    [queue addOperation:parser]; // this will start the "ParseOperation"

    [parser release];
    [queue release];
    // ownership of mediaListData has been transferred to the parse operation
    // and should no longer be referenced in this thread
    self.listData = nil;
}

- (void)dealloc 
{
    [records release];
    [listFeedConnection release];
    [listData release];
    [queue release];

    [super dealloc];
}

1 个答案:

答案 0 :(得分:0)

如果错误消息来自Xcode静态分析器,请记住它不完美,可能有误报。实际上,我没有看到您的代码有任何问题,但建议尝试并将其替换为:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    self.listFeedConnection = nil;   // release our connection

    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;   

    // create the queue to run our ParseOperation
    self.queue = [[[NSOperationQueue alloc] init] autorelease];

    // create an ParseOperation (NSOperation subclass) to parse the RSS feed data so that the UI is not blocked
    // "ownership of mediaListData has been transferred to the parse operation and should no longer be
    // referenced in this thread.
    //
    ParseOperation *parser = [[[ParseOperation alloc] initWithData:listData delegate:self] autorelease];

    [queue addOperation:parser]; // this will start the "ParseOperation"

    // ownership of mediaListData has been transferred to the parse operation
    // and should no longer be referenced in this thread
    self.listData = nil;
}