2011-08-11 25 views
1

アナライザーは、最初と最後に*という行にリークがあると言っていますが、このリークを修正して警告を取り除くにはどうすればよいでしょうか?このリークを修正するにはどうすればよいですか?

+ (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]; 
+0

ありがとう!私はこの答えを9分後に受け入れます –

関連する問題