I have an application called myApplication. It consists of two classes called FirstView and SecondView. myApplicationAppDelegate has member object – NSMutableArray called myArray. FirstView has member object myApplicationAppDelegate *delegate. In one of SecondView’s methods i’m doing the following:
myApplicationAppDelegate * myAppDelegate = [[UIApplication sharedApplication] delegate];
[myAppDelegate.myArray setArray:anotherArray];
OK
then in FirstView i want to save delegate.myArray to NSUserDefaults.
The question is – has delegate.myArray changed after i set anotherArray for myAppDelegate.myArray in the different file? What will i save? Old data or new?
If you call the
SecondViewmethod (the one you listed) before calling to save the array fromFirstView, then yes – you will be saving the new array. The array is changed immediately after you call to change it, not at some later time. Code in your app executes sequentially, regardless of which class you are calling from.