ios - updating mutable array in table view -
i'm newbie ios. have problem nsmutablearray
. hope me
my app has 2 view controllers (home , list).
in list , have nsmutablearray
self.arraycategory = [[nsmutablearray alloc]initwithobjects:@"1",@"2",@"3",@"4",@"5,@"6", nil]];
and put in view did load. use
[self.arraycategory insertobject:self.textfield.text atindex:1];
to add objects arraycategory
. works if in list view controller. not work when home go list again. display array has 6 elements. can please me find out solution. sorry bad english. all
probably recreate arraycategory when entering home screen. can check adding logging
nslog(@"here creating/recreating arraycategory");
also test (!) can try replace
self.arraycategory = [[nsmutablearray alloc]initwithobjects:@"1",@"2",@"3",@"4",@"5,@"6", nil]];
with
static nsmutablearray *staticarray; if (staticarray == nil) { staticarray = [[nsmutablearray alloc]initwithobjects:@"1",@"2",@"3",@"4",@"5",@"6", nil]; } self.arraycategory = staticarray;
in such case arraycategory not recreated solution not good. better use singleton or try place store arraycategory.
Comments
Post a Comment