Hello
I have a cover flow and it has 3 different image sets. One of them needs to be generated and I have been trying to get it populated with a thread for larger selections of images.
Here is a bit of my code:
- (void) startSongThread {
[NSThread detachNewThreadSelector:@selector(songThreadMain) toTarget:self withObject:nil];
}
- (void) songThreadMain {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int i = 0;
while(i < [items count] && ![[NSThread currentThread] isCancelled]) {
NSNumber *nsInt = [NSNumber numberWithInt:i];
if(![addedSongIndexes containsObject:nsInt]) [self setSongImage:nsInt];
i++;
}
[pool release];
}
- (void) stopSongThread {
if(![[NSThread currentThread] isCancelled]) [[NSThread currentThread] cancel];
}
The stopSongThread method gets called when the images change from one type to another.
If I load all the main images, switch image sets then switch back to the main set I always get EXC_BAD_ACCESS.
I tried to alloc the thread, but it only works once as well .. If i let it load and don't try to stop it, it works great.
Any help wuld be great, thanks!