I need to append two NSMUtableArray’s can any one suggest me how it possible?
My code is:
NSMutableArray *array1 = [appDelegate getTextList:1];
NSArray *array2 = [appDelegate getTextList:2];
[array1 addObjectsFromArray:array2];//I am getting exception here.
Anyone’s help will be much appreciated.
Thanks all,
Lakshmi.
What’s probably happening, is that your [appDelegate getTestList:1] is not actually returning a
NSMutableArray, but aNSArray. Just typecasting the array as mutable by holding a pointer to it like that will not work in that case, instead use:Or you could store the ‘textList’ variable that you have in your appDelegate as an NSMutableArray in the first place. I am assuming that you have an
NSArrayofNSArrays(or their mutable versions). Eg.Note: that you will probably have a different workflow, but I hope that you get the idea of storing the actual lists as NSMutableArrays.
Another Note: the second method WILL modify in place the
NSMutableArraythat[appDelegate getTextList:1];returns