I have a JSONModel class in my objective-c application. I use this class with a singleton then initialize this class with this code:
MyClass *client = [[MyClass alloc] init];
client = [[MyClass alloc] initWithDictionary:myDictionary error:nil];
.h
@interface MyClass : JSONModel
...
+ (id)sharedInstance;
...
@end
.m
static MyClass *singletonObject = nil;
+ (id) sharedInstance
{
if (! singletonObject) {
singletonObject = [[MyClass alloc] init];
}
return singletonObject;
}
- (id)init
{
if (! singletonObject) {
singletonObject = [super init];
}
return singletonObject;
}
I'm trying check if I had initialize my class like:
if([MyClass sharedInstance] == nil){
But it isn't working... How can I check if was initialized?