im kinda new to iOS, I’m having a hard time with my array, I’m using NSMutableArray,I have put my array in the AppDelegate,
At first load of the app in my viewController the array has no object in it yet, I have a setting that put my integers in the array,
but after saving the array was not loaded, but when exited then reOpen, it will load,
Could please someone explain how can I solve and why is it like this?
Im using it tableview.
in app delegate:
self.integers = [NSMutableArray array];
for(int i = 0; i <= 10; i++)
{ .....
}
loading:
integers = ((AppDelegate *)[[UIApplication sharedApplication] delegate]).integers;
My answer:
Somewhere in your code you have a loop that loads your integers and puts them into your array, right?
You need to put that loop in a method and call it again whenever you want to reset the
UITableVIewcontents back to its original contents.Then you need to update the array in your
AppDelegateand yourviewController, so depending which class that method is in, you’ll need to copy the integers to the other class usingor
Use the same code you used for the array originally to put all the integers back, then call
reloadDataon thetableview.That will solve your problem.