So I have a service clint class that has a method called fetch. I am invoking this method using NSInvocationOperation. and when I check the thread it seems like it's callin the mthod on the main thread. Isn't the whole point of using NSInvocationOperation to run things asynchronously?
Invoking method
ServiceClient *client = [[ServiceClient alloc] init];
NSInvocationOperation *invocatopnOperation = [[NSInvocationOperation alloc] initWithTarget:client selector:@selector(fetch) object:nil];
[invocatopnOperation start];
The method in service client
- (void)fetch
{
if ([[NSThread currentThread] isEqual:[NSThread mainThread]])
{
NSLog(@"NOOOOOO");
}
............
}
From NSInvocationOperation class reference:
The NSInvocationOperation class is a concrete subclass of NSOperation that manages the execution of a single encapsulated task specified as an invocation. You can use this class to initiate an operation that consists of invoking a selector on a specified object. This class implements a non-concurrent operation.
This means that in order to perform an operation asynchronously you need to add it to an operation queue.