2012-10-30 30 views
-3
NSMutableArray * lCellColValues = (NSMutableArray *) nil; 
lCellColValues = [[[NSMutableArray alloc] init] autorelease]; 

if (0 == lSecModulus) { 
    if cObjTransListPtr.count > 0 && lObjTransData.m_cObjSDElemInfoPtr.count > 0) { 
     [lCellColValues addObject: lObjTransData.m_cObjTransNamePtr]; 
     [lCellColValues addObject: [[NSNumber numberWithInteger: lObjTransData.m_cTransCounter] stringValue]]; 
    } else { 
     if (nil != lObjSDElemInfo.m_cObjStartTimePtr) { 
      NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init]; 
      dateFormatter.dateFormat = @"HH:mm:ss"; 
      [dateFormatter setTimeZone: [NSTimeZone timeZoneForSecondsFromGMT: 0.0]]; 
      NSString * myDateAsString = [dateFormatter stringFromDate: lObjSDElemInfo.m_cObjEndTimePtr]; 
      [lCellColValues addObject: myDateAsString]; 
      SAFE_RELEASE(dateFormatter) 
     } else { 
      [lCellColValues addObject: @""]; 
     } 

    [lCellColValues addObject: [[NSNumber numberWithDouble: lObjSDElemInfo.m_cElementTime] stringValue]]; 
    } 
} 

if ((CustSplitCell *) nil == lObjCellPtr) { 
    if (m_cObjTransListPtr.count > 0) { 
     lObjCellPtr = [[[CustSplitCell alloc] initWithStyleAndTitles: UITableViewCellStyleDefault reuseIdentifier: lObjCellIdentifier titles: lCellColValues rowNumber: indexPath.row] autorelease]; 
    } else { 
     [lCellColValues addObject: @""]; 
     lObjCellPtr = [[[CustSplitCell alloc] initWithStyleAndTitles: UITableViewCellStyleDefault reuseIdentifier: lObjCellIdentifier titles: lCellColValues rowNumber: indexPath.row] autorelease]; 
    } 
} 
+1

你能讀懂你已經粘貼在這裏的代碼? –

+0

我無法編輯代碼。請嘗試瞭解@ Praveen S – user1785195

+0

如果有人給出答案,他們將得到很好的讚賞。 – user1785195

回答

1

也許這可以幫助你: http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/MemoryMgmt/Articles/MemoryMgmt.html

我認爲你需要確保你使用自動釋放在適當情況下,保留在適當情況下,等等。如果你只是使用alloc/init而不進行autoreleasing,那麼在完成後你需要確保你有一個參考,你可以自己釋放它。當你這樣做時,你完全擁有該物品。這些都包含在我鏈接的規則中。

注意,這個答案是一條評論在這個問題上的副本:Memory leak for object in array

+1

謝謝yu沒有給developer.apple.com作爲參考。我的意思是我們知道我們可以訪問網站中的內存管理細節 – user1785195