Inter-ViewController options passing in iPhone programming ... how?

I read: iPhone: how to transfer data between multiple Viewbar dispatchers in a Tabbar application and wondered what the difference is between

[[UIApplication sharedApplicaton] delegate]

and

extern struct* global

?

Conceptually, I do not see how [[UIApplication sharedApplicaton] delegate] is not global. In fact, this reduces guilt by using a dirty global structure * now.

I am starting a new project very soon. So, I use this gap to ask the question: is there an example of the best example to illustrate how to exchange data between two ViewControllers (but not globally)?

Let me give an example:

  • It's a game
  • there is an NSString * name for storing the player name
  • NSInteger,
  • GameMainViewController
  • GameSettingViewController reset score
  • GameMainViewController ( nil), , ( )

  • "" ""?

!

+2
1

NSUserDefaults.

:

NSString *name = [[NSUserDefaults standardUserDefaults]objectForKey:@"name"];

:

[[NSUserDefaults standardUserDefaults]setObject:@"Horace" forKey:@"name"];

, , , plist.

+3

Source: https://habr.com/ru/post/1744715/


All Articles