ios - Trouble Using NSKeyedUnarchiver during init -


i have created facebookmanager singleton gets called on background thread when app launches. working fine facebook manager singleton, app etc. however, when app first launches, quite few seconds before useful because facebook manager has not finished doing thing yet. want do, use nskeyedarchiver save facebookmanager , dictionaries upon launch, app has navigable interface while facebook data being updated in background. make sense?

all within facebookmanager.m, first, when manager done updating friends dictionaries, etc, call method saves data:

- (bool)savefacebookdata {     // returns success or failure     nsstring *path = [self archivepath]; // helper method      return [nskeyedarchiver archiverootobject:self tofile:path]; } 

then in init, trying this, doesn't seem work. :

-(id)init {     self = [super init];      nsstring *path = [self archivepath];     self = [nskeyedunarchiver unarchiveobjectwithfile:path];      // if manager hadn't been saved previously, create new new 1      if (!self) {           if (_idsbynamedict == nil) {             _idsbynamedict = [[nsmutabledictionary alloc] init];         }          if (_photosbynamedict == nil) {             _photosbynamedict = [[nsmutabledictionary alloc] init];         }          if (_installedbynamedict == nil) {             _installedbynamedict = [[nsmutabledictionary alloc] init];         }          if (_allfriendsarray == nil) {             _allfriendsarray = [[nsarray alloc] init];         }          basicpermissions = no;         extendedpermissions = no;          // create synchronous dispatch queue facebook activity         if (_facebookupdatequeue == nil) {             _facebookupdatequeue = dispatch_queue_create("com.facebookupdatequeue", null);         }      } 

i think general strategy sound tripping on how grab archived version of manager during init! advice?

your class needs implement <nscoding> , both of methods encodewithcoder: archive of property values , initwithcoder: in archive them. make sure call super in implementations. generally, class using archived class know archiving hide knowledge in init using initforreadingwithdata: create nskeyedunarchiver , calling [self initwithcoder:...];.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -