Last Updated: February 25, 2016
·
412
· sherlockyao

iOS UI background code template

/* learned from http://www.objc.io/issue-2/common-background-practices.html */
__weak id weakSelf = self;
[self.operationQueue addOperationWithBlock:^{
    NSNumber* result = findLargestMersennePrime();
    [[NSOperationQueue mainQueue] addOperationWithBlock:^{
        MyClass* strongSelf = weakSelf;
        strongSelf.textLabel.text = [result stringValue];
    }];
}];