Singleton class method in static library in iOS -


i have static library contains singleton class method, call in (ibaction) function, first time call ok, second crashed, , no error information, singleton class method follows:

   +(myclass *)sharedclient{     static myclass *_sharedclient = nil;     static dispatch_once_t oncetoken;      dispatch_once(&oncetoken, ^{         _sharedclient = [[[myclass alloc] init] autorelease];      });      return _sharedclient;     } 

and call follows:

   -(ibaction) action      {         [myclass sharedclient] action];     } 

you're sending autorelease new object inside shared accessor. next time autorelease pool pops, shared object released , destroyed. remove autorelease, , crash should fix itself.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -