`
374016526
  • 浏览: 96337 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

关与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];

}

}

}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics