我使用NSThread在独立线程上创建一个对象。
NSThread* myThread = [[[NSThread alloc] initWithTarget:self selector:@selector(createNewObject:) object:elements] autorelease];
[myThread start]; // Actually start the thread该对象等待事件。当该事件发生时,通知将被发送到默认的通知中心。
我的AppController观察这个通知并运行一个选择器。
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(myMethod:) name:MyNotification object:nil];问题:是从选择器上运行的方法(myMethod:)在主线程上运行还是在上面(myThread)的线程上运行?
发布于 2011-11-24 23:57:38
https://stackoverflow.com/questions/8263576
复制相似问题