I want to keep one single object in application, and do not release.
@implementation MyClass
static MyClass *sharedInstance = nil;
+ (MyClass *)sharedInstance {
if (!sharedInstance) {
sharedInstance = [[super alloc] init];
}
return sharedInstance;
}
@end
I can get single object by [MyClass sharedInstance]
, it works well in Non-ARC mode.
But the object will release when change to ARC mode.