Objective-c에서 Thread의 생성.
1. class method 이용.
[NSThread detachNewThreadSelector:@selector(myThreadMainMethod:) toTarget:self withObject:nil];
2. 직접 생성하여 이용.
NSThread* myThread = [[NSThread alloc] initWithTarget:self
selector:@selector(myThreadMainMethod:)
object:nil];
[myThread start];
thread의 종료 시점에 어떤 작업 하기. (NSThreadWillExitNotification 이용)
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(afterWork:)
name:NSThreadWillExitNotification
object:nil];
'Apple > Tip' 카테고리의 다른 글
[iPhone Tip] thread 사용하기. (0) | 2009.07.21 |
---|---|
[iPhone Tip] UITextField에서 Enter Key입력시에 자판 사라지게 하기 (0) | 2009.07.19 |
TAG defaultCenter,
detachNewThreadSelector,
iphone,
NSNotificationCenter,
NSThreadWillExitNotification,
Objective C,
Thread
댓글을 달아 주세요