Singleton design potential leak
- by iBrad Apps
I have downloaded a library off of github and have noticed that in the main singleton of the library there is a possible leak in this bit of code:
+(DDGameKitHelper*) sharedGameKitHelper
{
@synchronized(self)
{
if (instanceOfGameKitHelper == nil)
{
[[DDGameKitHelper alloc] init];
}
return instanceOfGameKitHelper;
}
return nil;
}
Now obviously there is no release or autorelease anywhere so I must do it but how and in what way properly? I have looked at various Singleton design patterns on the Internet and they just assign, in this case, instanceOfGameKitHelper to the alloc and init line.
Anyway how would I properly fix this?
Thanks!