I have a method in my application that goes through all subscribed feeds in my application's PubSub Client and marks all the entries as read. When the number of entries it has to go through gets up into the hundreds this take up a significant amount of time, relatively speaking.
The code for the method looks like this...
I want this to be able to run in the background while the user would still be able to interact with the UI in the foreground. So I set up a NSInvocationOpertion and NSInvocationQueue to handle this operation. The code looks like this.
Unfortunately the UI is very unresponsive when this operation is taking place and has extreme lag. I'm unsure as to why this is the case, I was under the impression that this could be avoided when using NSInvocationOperation.
I haven't used Time Profiler in instruments before, nor do I know what exactly would I be looking for. From what I can tell, it seems PubSub is taking up the highest percentage while the event is occurring. While exploring the symbol names my method is occurring on "_dispatch_worker_thread2" while the actual PubSub operations like "sendChangesSinceDate" (which is taking up the highest percentage while my operation is working) is occuring on the "Thread 0x5565 : Main Thread". Does this seem correct?
Any help is appreciated, thanks in advance!
The code for the method looks like this...
Code:
-(void)markAllReadOperation
{
NSArray *feeds = [[PSClient applicationClient]feeds];
for(PSFeed *feed in feeds)
for(PSEntry *entry in [feed entries])
entry.read = YES;
}
I want this to be able to run in the background while the user would still be able to interact with the UI in the foreground. So I set up a NSInvocationOpertion and NSInvocationQueue to handle this operation. The code looks like this.
Code:
NSInvocationOperation *opr = [[NSInvocationOperation alloc]initWithTarget:self selector:@selector(markAllReadOperation) object:nil];
[queue addOperation:opr];
[opr release];
Unfortunately the UI is very unresponsive when this operation is taking place and has extreme lag. I'm unsure as to why this is the case, I was under the impression that this could be avoided when using NSInvocationOperation.
I haven't used Time Profiler in instruments before, nor do I know what exactly would I be looking for. From what I can tell, it seems PubSub is taking up the highest percentage while the event is occurring. While exploring the symbol names my method is occurring on "_dispatch_worker_thread2" while the actual PubSub operations like "sendChangesSinceDate" (which is taking up the highest percentage while my operation is working) is occuring on the "Thread 0x5565 : Main Thread". Does this seem correct?
Any help is appreciated, thanks in advance!