开发者

iPad: NSAutoreleasePool with animation, and release confusion

开发者 https://www.devze.com 2023-01-19 20:26 出处:网络
I have two related questions concerning NSAutoreleasePool. Between declaring the pool and draining it, can I use animation? Example

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消