I've got a strange thing happening I dont understand. if I run the method [self setImage:[UIImage imageNamed:@"Loader20.png"]] eg. it works fine outside the thread selector method, but it wont work in the selector method itself, it just does nothing. here is the way I do it.
- (id)init {
self = [super init];
if (self) {
//[self setImage:[UIImage imageNamed:@"Loader20.png"]];
[NSThread detachNewThreadSelector:@selector(showLoadingImage) toTarget:self withObject:nil];
}
return self;
}
-(void)showLoadingImage{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int i = 0;
int imageIncrement= 1;
bool run = true;
while (run){
[NSThread sleepForTimeInterval:1];
if(imageIncrement == 48){
imageIncrement=1;
i++;
}else{
imageIncrement++;
}
NSString *imageString = [NSString stringWithFormat:@"%@%d%@", @"Loader", imageIncrement, @".png"];
NSLog(imageString);
[self setImage:[UIImage imageNamed:imageString]];
if (i == 2){
run = false;
[NSThread exit];
}
}
[pool release];
}
Can anyone give me some directions, I made sure all the images I want to loop through are correctly named testing with NSlog but still the image doesnt change.
Thanks in advance. Brett