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
Post a Comment