moving a function to a background thread in objective c

Well that’s pretty easy actually with GCD. A typical workflow would be something like this:

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul);
dispatch_async(queue, ^{
    // Perform async operation
    // Call your method/function here
    // Example:
    NSString *result = [anObject calculateSomething];
    dispatch_async(dispatch_get_main_queue(), ^{
        // Update UI
        // Example:
        self.myLabel.text = result;
    });
});

For more on GCD you can take a look into Apple’s documentation here

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)