什麼是可能發生的,是你的[的appDelegate getTestList:1]實際上沒有返回NSMutableArray
,但NSArray
。只是類型轉換數組作爲可變通過保持它的指針一樣,不會在這種情況下工作,而是使用:
NSMutableArray *array1 = [[appDelegate getTextList:1] mutableCopy];
NSArray *array2 = [appDelegate getTextList:2];
[array1 addObjectsFromArray:array2];
或者你可以存儲在您的appDelegate具有作爲一個NSMutableArray在「文本清單」變量第一個地方。我假設你有NSArray
的NSArrays
(或他們的可變版本)。例如。
// In the class interface
NSMutableArray *textLists;
// In the function in which you add lists to the array
NSMutableArray *newTextList;
[self populateArray:newTextList]; // Or something like that
[textLists addObject:newTextList];
注:,你可能有不同的工作流程,但我希望你存儲的實際列爲NSMutableArrays的想法。
另注:第二種方法WILL修改的地方NSMutableArray
是[appDelegate getTextList:1];
回報
你有什麼異常? – willcodejavaforfood 2010-09-28 08:02:27
這是我得到的異常: – 2010-09-28 08:49:15
2010-09-28 14:18:10.685 VoiceMessenger [3147:307] ***由於未捕獲異常'NSGenericException'而終止應用程序,原因:'*** Collection <__ NSArrayM:0x166090 >突變而被枚舉( 「」, 「」, 「」, 「」, 「 「 」「, 」「, 」「, 」「, 」「, 」 「 )' –
2010-09-28 08:49:44