objective c - How to append two NSMutableArray's in Iphone sdk or append an NSArray With NSMutableArray? -
objective c - How to append two NSMutableArray's in Iphone sdk or append an NSArray With NSMutableArray? -
i need append 2 nsmutablearray's can 1 suggest me how possible?
my code is:
nsmutablearray *array1 = [appdelegate gettextlist:1]; nsarray *array2 = [appdelegate gettextlist:2]; [array1 addobjectsfromarray:array2];//i getting exception here. anyone's help much appreciated.
thanks all, lakshmi.
what's happening, [appdelegate gettestlist:1] not returning nsmutablearray, nsarray. typecasting array mutable holding pointer not work in case, instead use:
nsmutablearray *array1 = [[appdelegate gettextlist:1] mutablecopy]; nsarray *array2 = [appdelegate gettextlist:2]; [array1 addobjectsfromarray:array2]; or store 'textlist' variable have in appdelegate nsmutablearray in first place. assuming have nsarray of nsarrays (or mutable versions). eg.
// in class interface nsmutablearray *textlists; // in function in add together lists array nsmutablearray *newtextlist; [self populatearray:newtextlist]; // or [textlists addobject:newtextlist]; note: have different workflow, hope thought of storing actual lists nsmutablearrays.
another note: sec method will modify in place nsmutablearray [appdelegate gettextlist:1]; returns
objective-c
Comments
Post a Comment