1使用gcd
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Do the work in background
});
2.使用performSelectorInBackground方法
[self performSelectorInBackground:@selector(myMethod:)
withObject:myObj];
對應的方法:- (void)myMethod:(id)myObj;
其中方式1適應性強,使用方便,唯一可能是缺點的地方就是使用了gcd+block,代碼看上去略長,不過習慣了這種語法也不是什麼問題,推薦方式1.