Singleton Class sample

//.h file should contain

+ (MySingleton *)sharedInstance;

 

//.m file must declare as below

+ (MySingleton *)sharedInstance

{

static dispatch_once_t once;

static MySingleton *instance;

dispatch_once(&once, ^{

instance = [[MySingleton alloc] init];

});

return instance;

}

– (id)init

{

if (self = [super init])

{

     someProperty =@”test”;

}

return self;

}

tips & tricks

Join 7,719 other subscribers

interview questions


Algorithm Android Android Studio API APP Programming Apps blogging Browser CheatSheets Code Config CSS DATABASE dsa error Features HTML HTML5 IDE installation Interview Questions IOS iPhone javascript Mac objective-c OneDrive OS Placeholder Programming quicktips SDK SEO Settings SMO SQL swift swiftUI Teams Tips & Tricks Tools UI Web Wordpress Xcode


Archives

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from CODE t!ps

Subscribe now to keep reading and get access to the full archive.

Continue reading