2011-12-05 4 views
0

helper.offlineQueue 행에 누출이 발생하여 NSOperationQueue 객체를 할당합니다. 문제는이 방법으로 어디에서 해제 할 것인지 잘 모르겠습니다 ...이 누설을 고치는 방법?

+ (void)flushOfflineQueue 
{ 
    // TODO - if an item fails, after all items are shared, it should present a summary view and allow them to see which items failed/succeeded 

    // Check for a connection 
    if (![self connected]) 
     return; 

    // Open list 
    NSMutableArray *queueList = [self getOfflineQueueList]; 

    // Run through each item in the quietly in the background 
    // TODO - Is this the best behavior? Instead, should the user confirm sending these again? Maybe only if it has been X days since they were saved? 
    //  - want to avoid a user being suprised by a post to Twitter if that happens long after they forgot they even shared it. 
    if (queueList != nil) 
    { 
     SHK *helper = [self currentHelper]; 

     if (helper.offlineQueue == nil) 
      helper.offlineQueue = [[NSOperationQueue alloc] init];  

     SHKItem *item; 
     NSString *sharerId, *uid; 

     for (NSDictionary *entry in queueList) 
     { 
      item = [SHKItem itemFromDictionary:[entry objectForKey:@"item"]]; 
      sharerId = [entry objectForKey:@"sharer"]; 
      uid = [entry objectForKey:@"uid"]; 

      if (item != nil && sharerId != nil) 
       [helper.offlineQueue addOperation:[[[SHKOfflineSharer alloc] initWithItem:item forSharer:sharerId uid:uid] autorelease]]; 
     } 

     // Remove offline queue - TODO: only do this if everything was successful? 
     [[NSFileManager defaultManager] removeItemAtPath:[self offlineQueueListPath] error:nil]; 

    } 
} 

고마워요!

답변

1

나는 당신이 단지해야 기대 :

helper.offlineQueue = [[[NSOperationQueue alloc] init] autorelease]; 

SHK 객체 자체가 큐를 유지해야하며이 완료되면이를 발표 할 예정이다. alloc으로 인해 보유하고있는 참조는 즉시 공개 될 수 있습니다.

관련 문제