我正在为iOS编写一个多线程应用程序。 我是Objective-C的新手,所以在iPhone之前我还没有玩过线程。可可触摸线程问题
通常使用Java的时候,我创建一个线程,并发送“自我”为对象的线程。并从我可以为线程调用主线程。 这是如何在Objective C中完成的?
如何从线程调用主线程?我一直NSNotificationCenter尝试,但我得到一个错误sigbart:/
这是线程的启动方式:
NSArray *extraParams = [NSArray arrayWithObjects:savedUserName, serverInfo, nil]; // Parameters to pass to thread object
NSThread *myThread = [[NSThread alloc] initWithTarget:statusGetter // New thread with statusGetter
selector:@selector(getStatusFromServer:) // run method in statusGetter
object:extraParams]; // parameters passed as arraylist
[myThread start]; // Thread started
activityContainerView.hidden = NO;
[activityIndicator startAnimating];
任何帮助将是巨大的!