I am using NSThread to create new thread that displays images in my application. On the main thread I am working with a table view which is displaying data from XML file, in the same view I am displaying images below. But, displaying images on new thread is not working properly.
- (void)viewDidLoad {
[super viewDidLoad];
[NSThread detachNewThreadSelector:@selector(startTheBackgroundJob) toTarget:self withObject:nil];
}
And the method in question:
- (void)startTheBackgroundJob {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
currentLocationImageView = [[UIImageView alloc] init];
NSArray *images = [NSArray arrayWithObjects:img1, img2, nil];
[currentLocationImageView setAnimationImages:images];
[currentLocationImageView setAnimationRepeatCount:0];
[currentLocationImageView setAnimationDuration:5.0];
[self.view addSubview:currentLocationImageView];
[pool release];
}
now that you’ve started accepting the answers….
Without even looking at your code, the first thing to tell you is, you MUST perform UI activities on main thread… check this question for details…