Created
July 15, 2011 05:57
-
-
Save marshluca/1084158 to your computer and use it in GitHub Desktop.
[NSThread detachNewThreadSelector]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (IBAction)clickButton | |
{ | |
[NSThread detachNewThreadSelector:@selector(startBackgroundJob) | |
toTarget:self | |
withObject:nil]; | |
} | |
- (void)startBackgroundJob | |
{ | |
[self performSelectorOnMainThread:@selector(makeProgressBarMoving) | |
withObject:nil | |
waitUntilDone:NO]; | |
} | |
- (void)makeProgressBarMoving | |
{ | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
float actual = [progressBar progress]; | |
if (actual < 1) | |
{ | |
progressBar.progress += 0.01; | |
[NSTimer scheduledTimerWithTimeInterval:0.5 | |
selector:@selector(makeProgressBarMoving) | |
userInfo:nil | |
repeats:NO]; | |
} | |
[pool release]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment