Create NSThread in iPhone using Objective-C
1. Create a NSThread as follows.
[NSThread detachNewThreadSelector:@selector(threadMethod)
toTarget:self
withObject:nil];
2. Define the threadMethod in the code.
- (void)threadMethod {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
/** add the code for the new thread **/
[pool release];
}
[NSThread detachNewThreadSelector:@selector(threadMethod)
toTarget:self
withObject:nil];
2. Define the threadMethod in the code.
- (void)threadMethod {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
/** add the code for the new thread **/
[pool release];
}
Comments
Post a Comment