关与NSThread的退出

当View离开父窗口之前将Thread结束掉 这样就能有效的管理线程和逻辑处理了

 

- (void)login {

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

thread = [NSThread currentThread];

sleep(3.0f);

if (![thread isCancelled]) {

thread = nil;

} else {

thread = nil;

}

 

[pool release];

}

 

 

- (void)willMoveToSuperview:(UIView *)newSuperview {

if (!newSuperview) {

if (thread) {

[thread cancel];

}

}

}


猜你喜欢

转载自374016526.iteye.com/blog/1160057