Skip to content

Instantly share code, notes, and snippets.

@marshluca
Created July 15, 2011 05:57
Show Gist options
  • Save marshluca/1084158 to your computer and use it in GitHub Desktop.
Save marshluca/1084158 to your computer and use it in GitHub Desktop.
[NSThread detachNewThreadSelector]
- (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