tags:

views:

17

answers:

2

Hi, using xcode I would like to achieve a public shared class that stores its own data. So, if I'm in one class I can call it from another and retain persistence.

For example,

I have multiple viewcontrollers for an iPhone project. When the app is opened, it checks with a seperate service if that player is logged in and returns some information. Let's call it GamePlacenta. I need to store certain information about the player in the GamePlacenta class, like user_id etc. But I need to be able to access it from any other class later on. I don't want to store it in text files, memory is good.

What do I need to be looking into?

+3  A: 

You need to use a Singleton. It does exactly what you want it to--holds one set of data that you can access anywhere. Here is a great tutorial on creating one. It's just a few lines of code, and can store anything.

MishieMoo
Wahoo! I hope it works. GAMEPLACENTA HERE I COME
meridimus
+1  A: 

Sounds like you need a Singleton class. See this Wikipedia article.

RichB