2012-06-20 58 views
0
- (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]; 
} 
+0

道歉 - 我得到NSOperationQueue上的錯誤。顯然沒有正確釋放。請指教。 – user1470105

+0

錯誤究竟是什麼? 「顯然沒有正確發佈」是什麼意思? –

+0

NSOperationQueue 1.方法返回帶有+1保留計數的Objective-C對象。 然後在解析器代碼2.對象泄漏:稍後未引用的分配的對象。 – user1470105

回答

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; 
} 
+0

謝謝!它是靜態的Xcode分析器。歡迎在代碼海中幫助平面設計師。 – user1470105