2012-06-20 1 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. Метод возвращает объект Objective-C со значением сохранения +1. Затем на код Parser 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

Смежные вопросы