iphone - Objective C: store variables accessible in all views -
greetings,
i'm trying write first iphone app. have need able access data in views. data stored when user logs in , needs available views thereafter.
i'd create static class, when try access static class, application crashes no output on console.
is way write data file? or there cleaner solution haven't thought of?
many in advance,
use singleton class, use them time global data manager classes need accessible anywhere inside application. can create simple 1 this:
@interface newsarchivemanager : networkdatamanager { } + (newsarchivemanager *) sharedinstance; @end @implementation newsarchivemanager - (id) init { self = [super init]; if ( self ) { // custom initialization goes here } return self; } + (newsarchivemanager *) sharedinstance { static newsarchivemanager *g_instance = nil; if ( g_instance == nil ) { g_instance = [[self alloc] init]; } return g_instance; } - (void) dealloc { [super dealloc]; } @end
Comments
Post a Comment