February 2014
Intermediate to advanced
560 pages
18h 58m
English
Thus far, we have only talked about single-threaded apps. A single-threaded app only uses one core and is executing only one function at a time. Multithreaded apps can execute multiple functions simultaneously on different cores.
In Chapter 11, you created a singleton like this:
+ (instancetype)sharedStore
{
static BNRImageStore *sharedStore = nil;
if (!sharedStore) {
sharedStore = [[self alloc] initPrivate];
}
return sharedStore;
}
// No one should call init
- (instancetype)init
{
[NSException raise:@"Singleton"
format:@"Use +[BNRImageStore sharedStore]"];
return nil;
}
- (instancetype)initPrivate
{
self = [super init];
if (self) {
_dictionary = [[NSMutableDictionary alloc] init];
}
return self;
}
Read now
Unlock full access