Reputation: 13860
I have a part of data that only should be read once. I have ivars in there and want to store them somewhere to have access from my controller. Where should I put it? I'd rather avoid subclassing in this case. My reader should be passing data from some other class, and the other class may be a parent class for something. Am i right?
So my question is: I have some data after my app starts, and where do i have to put it?
Upvotes: 0
Views: 266
Reputation: 5393
As mentioned in other answers you could just store it in your appDelegate. If it's not much data then I personally don't see any problem in storing it in the appDelegate.
(I think some people can get too hung up on the "right" or "wrong" way of doing things - if this is a small app and nobody else is going to be working on this app with you then do what's easy as long as your app and your users don't suffer).
If it's lots of data though, or if in future you might want to extend this data significantly I would avoid doing so. In which case, it would be better to create a separate singleton model class to store the data in.
Upvotes: 0
Reputation: 8267
Set an array in your appDelegate then from anywhere:
MyAppDelegateClass *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate someMethod:..];
Upvotes: 2
Reputation:
@ SimpleMan :- Which type of data u have ? Text , Image , Video ?
I think you have text data right ? for text data you can use plist.. or Sqlite database also. Which you want. in this case the data will be store permanently. If you want to store data temporary i.e once (existence only in the duration of app running) you can store the data in variables.
in your case while your app is starting you are getting data from server right ? then you should to store that data in application delegate files. i.e AppDelegate.m file.
and use where u want to access. If u have any query then reply me.
Upvotes: 0