1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#import "Thing.h" @interface Thing () @end @implementation Thing + (instancetype)thing { static Thing* thing = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ thing = [[[self class] alloc] init]; }); return thing; } - (void)sayHello { NSLog(@"Hello World"); } @end