2013-02-18 55 views
2

我不明白爲什麼,如果我寫的這些代碼ALLOC initWithObjects VS arrayWithObject

icons = [[NSArray alloc] initWithObjects: 
      @"appointment", 
      @"work", 
      @"anniversary", 
      @"me", 
      nil]; 

應用程序崩潰。但後來我用這些代碼替換了

icons = [NSArray alloc] arrayWithObjects: 
      @"appointment", 
      @"work", 
      @"anniversary", 
      @"me", 
      nil]; 

並且該應用沒有崩潰。 但這些方法之間有相同的影響! 我不知道爲什麼?你能幫我嗎 ?

+1

http://stackoverflow.com/questions/5155097/ipad-large-nsarray-initwithobjects-vs-arraywithobjects – 2013-02-18 09:10:36

+1

提供了一些更多的代碼和崩潰日誌。 – 2013-02-18 09:12:03

+0

Plz檢查這個http://stackoverflow.com/questions/6744468/what-is-the-difference-between-arraywithobjects-and-initwithobjects – HRM 2013-02-18 09:28:09

回答

1
  1. initWithObjects方法意味着你必須釋放每當這不是必須的,因爲這是實例方法數組的對象,併爲更多的細節click

  2. arrayWithObjects方法意味着你不需要釋放每當這不是必需的,因爲這是類方法數組的對象,併爲更多的細節click

如果你不與積分清零,從而恢復我..

+0

謝謝你。我忘了發佈:P – Proton 2013-02-20 06:34:56