NSThread 백그라운드 쓰레드 돌리기

프로그래밍을 하다 보면 느끼겠지만 쓰레드는 필수이다.

iPhone에서 백그라운드쓰레드를 돌려보자..

Objective-c 에서는 NSThread 라는 클래스가 있다.

일단 쓰레드 처리할 함수를 만든다.

-(void) myTestThread:(id)anObject {

     NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
     //이곳에 처리할 코드를 넣는다.
    
    [autoreleasepool release];
    [NSThread exit];

}


그리고 쓰레드를 호출한다.

[NSThread detachNewThreadSelector:@selector(myTestThread:) toTarget:self withObject:nil];

간단~

Posted by 마르스

2009/12/24 00:09 2009/12/24 00:09
, , ,
Response
No Trackback , No Comment
RSS :
http://lasel.kr/blog/rss/response/17


블로그 이미지

냉정함을 잃지말자...!!

- 마르스