views:

38

answers:

1

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!

A: 

This isn't a complete answer. But I've decided to switch my game plan a little on how I was using the thread.

Basically I crated a new empty class with a thread just to generate the thumbs. When I'm populating the cover flow I check to see if the thread class has built an image. This seems to work so far I will continue to tweak it until its super smooth!

Thanks

Paul Hart
Hmm, still having issues. It seems to fail when I need to do the following line of code: [thisPage.layer renderInContext:ctx];
Paul Hart