Guest User

Untitled

a guest
Apr 27th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. put this in the contructor of the class that will be the background thread:
  2.  
  3. NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  4. [NSThread detachNewThreadSelector:@selector(threadMethod:) toTarget:self withObject:nil];
  5. [pool release];
  6.  
  7.  
  8.  
  9. then in threadMethod
  10.  
  11.  
  12. - (void)threadMethod:(id)param
  13. {
  14. NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  15. while (YES) {
  16.  
  17. [NSThread sleepForTimeInterval:(float)SLEEP_TIME];
  18. //dostuff
  19. }
  20. [pool release];
  21. }
Add Comment
Please, Sign In to add comment