Question

I have made a call to a class method from the appDelegate like so:

    RankingAndSMProcess *process = [RankingAndSMProcess alloc];

    [process performSelectorInBackground:@selector(DoRankingAndSocialMediaProcessing) withObject:nil];

    [process release];

This method calls other methods:

     @try {
         [self GoForRankingProcess];
         [self updateItemsForPeerindex];
         [self updateItemsForKloat];
         [self updateItemsForKred];
     }
     @catch (NSException *exception) {
         NSLog(@"An Error has been occured:%@", exception);
     }
     @finally { 
         [items release];
         [profile release];
     }

Do all the methods called from within the DoRankingAndSocialMediaProcessing method in RankingAndSMProcess have to be called in the same way as the DoRankingAndSocialMediaProcessing on the background thread? Or is there another potential problem here?

Currently I don't think any of the processing methods are being fired since no new data is being gathered.

Before adding changing the call to perform in the background all the methods and entire process worked as expected.

Was it helpful?

Solution

Create a NSOperation and add this operation to NSOperationQueue. This will create a new thread parallel to main thread and it will execute your method as well.

Here are some useful links:

NSOperation on the iPhone

http://www.icodeblog.com/tag/nsoperation/

http://www.cimgf.com/2008/02/16/cocoa-tutorial-nsoperation-and-nsoperationqueue/

Hope this will help you.

Enjoy Coding :)

OTHER TIPS

What all are those other methods doing? If it is a network request for instance a run-loop may be needed in order for the background thread to actually be able to perform the task.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top