iOS:如何在后台线程中努力处理数据?

iOS:如何在后台线程中努力处理数据?,第1张

概述我有一个方法,如: - (BOOL)shouldDoSomeWork { BOOL result = // here I need do hard work with data in background thread and return result, so main thread should wait until the data is calculated and then ret 我有一个方法,如:

- (BOol)shouldDoSomeWork {   BOol result = // here I need do hard work with data in background thread and return result,so main thread should wait until the data is calculated and then return result;   return result;}

如何实现?

解决方法 你在找这个:

-(voID) startWork{     //Show activity indicator    [NSThread detachNewThreadSelector:@selector(doSomeWork) toTarget:self withObject:nil];}-(voID) doSomeWork{    NSautoreleasePool *pool = [NSautoreleasePool new];    //Do your work here    [pool release];    [self performSelectorOnMainThread:@selector(doneWork) withObject:nil waitUntilDone:NO];}  -(voID) doneWork{   //HIDe activity indicator  }
总结

以上是内存溢出为你收集整理的iOS:如何在后台线程中努力处理数据?全部内容,希望文章能够帮你解决iOS:如何在后台线程中努力处理数据?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1007078.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-22
下一篇2022-05-22

发表评论

登录后才能评论

评论列表(0条)

    保存