I have 2 View Controller's, one of them has a string (e.g. "Text1 Text2") that when a button gets pressed it saves it to default user data:
[[NSUserDefaults standardUserDefaults] setObject:textObject forKey:@"textObjectKey"];
This same button has a popover presentation segue onto the 2nd view controller that in its viewDidLoad
retrieves the string:
[[NSUserDefaults standardUserDefaults] stringForKey:@"textObjectKey"];
and calls a setText
method to a textView
to contain the string.
This does work, but my problem is that when I change the string (e.g. "Text1 Text2 Text3") and click the button the textView does not show the next text until I press it again. Not only that, but if I run the project again the first time I press the button it will have the text from the last time I ran the program (until I click it again).
Is this 'delay' something I can fix? Or is it a bug with iOS (I think this only because it keeps info from the previous program execution).
Fix edit: Rookie mistake. I put the statement that stores the string in user data inside of the button method with the segue.