ios - NSRunloop in Thread -
i problem
here code
- (void)start{ [[nsrunloop currentrunloop] rununtildate:[nsdate distantfuture]]; } - (void)nlog{ nslog(@"cool"); } - (void)main{ thread = [[nsthread alloc] initwithtarget:self selector:@selector(start) object:nil]; [thread start]; [self performselector:@selector(nlog) onthread:thread withobject:nil waituntildone:no]; } when call
[self performselector:@selector(nlog) onthread:thread withobject:nil waituntildone:no]; the thread keeping running , can in thread later;
but if don't call it, thread exit @ once , can never use thread anything, why?
when start thread, if don't add source runloop, run loop return immediately. thread finished.
check out:
Comments
Post a Comment