Objective-C: Allocation in one thread and release in other

Posted by user423977 on Stack Overflow See other posts from Stack Overflow or by user423977
Published on 2011-01-15T05:47:22Z Indexed on 2011/01/15 5:53 UTC
Read the original article Hit count: 163

Hi

I am doing this in my Main Thread:

CCAnimation *anim; //class variable

[NSThread detachNewThreadSelector:@selector(loadAimation) toTarget:self withObject:nil];

In loadAimation:

-(void) loadAimation {
    NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
        anim = [[CCAnimaton alloc] init];
        [autoreleasepool drain];
}

And in main thread I release it:

        [anim release];

Now I want to ask if this is fine regarding memory management.

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about multithreading