-1

I'm making a Hangman app in objective-c and want to include a statistics page which has stats on games played, games won, etc. I have 4 view controllers connected to their own .m files. One for the home page, one for single player, one for multiplayer, and one for statistics. How do you get information across one view controller to the other?

For example, if the user lost a game, how can I get that information across from the single player view controller to the statistics page?

(I can't include view controllers so I don't really know what code to include.)

Nick P
  • 19
  • 2
  • If you need the code described I will try to tell you. Just ask. – Nick P Nov 15 '14 at 03:20
  • You should **always** show your code, that way what you're describing is clear to those helping you. – l'L'l Nov 15 '14 at 03:24
  • 1
    There are countless questions like this on SO. For example: http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers – rebello95 Nov 15 '14 at 03:24

2 Answers2

0

You should create another object to store the data in your app delegate and pass pointers to the stored data object to your view controllers. This is called Model View Controller. The objects that store the data are called Model objects.

Nick Wilkerson
  • 353
  • 2
  • 17
0

Create a UIViewController class as common and create data instances for storing the game info in that class.

You can use this view controller as super class of all the 4 view controllers. i.e., you need to inherit that class instead of UIViewController.

Or you can create singleton object class to store the data.

Hope this may help you.

Neenu
  • 6,848
  • 2
  • 28
  • 54