如果我想在没有太多负载的情况下一次执行多个功能,那么哪个选项是最好的(为了减少负载、快速执行和崩溃问题)...
1). NS线程
2).在后台执行选择器
3). NSOperationQueue
或者除上述之外的任何其他?请建议我最好的和适当的解决方案。提前感谢所有链接和指导。
最佳答案
Grand Central Dispatch 是我认为最好的。
// Job 1
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
// Heavy work here...
});
// Job 2
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
// Heavy work here...
});
如果你想在主线程中做一些事情(例如更新用户界面),请使用:
dispatch_sync(dispatch_get_main_queue(), ^{
// Update UI...
});
关于iphone - 多项功能同时存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13582611/