objective c – iPad: NSAutoreleasePool with animation, and release confusion – Education Career Blog

I have two related questions concerning NSAutoreleasePool.

  1. Between declaring the pool and draining it, can I use animation? Example

    NSAutoreleasePool *pool = NSAutoreleasePool alloc init;
    subView.alpha = 0.10;
    UIView beginAnimations:nil context:NULL;
    UIView setAnimationDuration:1.0;
    UIView setAnimationDelegate:self;
    UIView setAnimationRepeatCount:1;
    subView.alpha = 1.0;
    UIView commitAnimations;
    pool drain; 
    
  2. If I alloc something after the pool is declared, do I release it before drain? After drain? Or not at all?

Edit: Code formatting is refusing to work for some reason. Could a mod please try to format the code above?

,

To answer part two… You should not be calling any other types either before the pool init or after the pool drain.

By the time the pool drains all your instances should be released.

Your animations look like they are in the correct place to me.

Leave a Comment