My question maybe is silly but i cannot understand this. I create a singleton class using this code.
+ (GameRequestHandler *) sharedInstance
{
static dispatch_once_t pred;
static GameRequestHandler *shared = nil;
dispatch_once(&pred, ^{
shared = [[GameRequestHandler alloc] init];
});
return shared;
}
When i call methods from this singleton object, are they called on the main thread or in a background thread?
The methods are called on the thread you invoke them from.
dispatch_oncejust ensures that the block passed to it is only executed once in the lifetime of the application. I don’t think it uses threads and if it does, that is an implementation detail you don’t need to worry about.