My iOS app uses a C function for some computing. I want to call it from -(void)viewDidLoad but I don't want it to freeze the main thread. I tried calling it with dispatch_async(dispatch_get_main_queue... block but it still was being called on the main thread. Also including function call into objective-c method and calling [self performSelector: InBackground] didn't work either. Please help. Is there any way I can perform C function in background in objective-c app ?
0
votes
2 Answers
2
votes
You have to use a different queue, e.g.:
dispatch_queue_t backgroundQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(backgroundQueue, ^{
// do something
});
See Dispatch Queues for more details.
dispatch_get_main_queue()is the problem. You have to use a different queue. - Sulthan