Demo entry 6324467

oc method

   

Submitted by anonymous on Nov 18, 2016 at 14:59
Language: Objective-C. Code size: 246 Bytes.

@implementation SingletonObject

static id instance;

+ (instancetype)sharedInstance
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[self alloc]init];
    });
    return instance;
}

@end

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).