Kyle et al,

No problem -- here's my code. There is obviously something i'm not getting, so any help is truly appreciated.

First, my view controller has a showAnimation method that is called to play the currently loaded animation:

- (void)showAnimation
{
    // only play the animation if the preloader thread has finished ...

lilappAppDelegate *delegate = (lilappAppDelegate *) [[UIApplication sharedApplication] delegate];

    [delegate stopAnimations];

    if(YES == delegate.animationPreloaded)
    {
delegate.animationView.animationImages = delegate.animationArray;
        [delegate playAnimation:self.view];
        [delegate preloadNextAnimation];
    }
}

... and I run a thread to preload the next animation (this code always preloads the same one, but the idea is that they'll change, and I don't want to load them all at once and waste memory):

- (void)preloadAnimationThread
{
    NSAutoreleasePool *outerPool = [[NSAutoreleasePool alloc] init];

    self.animationPreloaded = NO;
    int frameIndex = 0;

    [NSThread sleepForTimeInterval:5];

[self performSelectorOnMainThread:@selector(releaseAnimations) withObject:nil waitUntilDone:YES];

    [self.animationArray release];
    self.animationArray = [[NSMutableArray alloc] init];

    for (frameIndex = 0; frameIndex < 47; frameIndex += 2)
    {
NSString *frameName = [NSString stringWithFormat:@"clapping_ %05i.png", frameIndex];
        
// I tried [UIImage imageContentsFromFile], but it resulted in animations that played on the sim but
        // not on the device ...

        [self.animationArray addObject:[UIImage imageNamed:frameName]];
    }

    self.animationPreloaded = YES;

    [outerPool release];
}

- (void)releaseAnimations
{
    self.animationView.animationImages = nil;
}

- (void)stopAnimations
{
    [self.animationView stopAnimating];
}

On Aug 8, 2009, at 10:24 PM, Kyle Sluder wrote:

On Aug 8, 2009, at 8:14 PM, John Michael Zorko <jmzo...@mac.com> wrote:

My question -- what is the correct way to release the UIImageView's animatedImages array? I assign an NSMutableArray to it, play the animation, then set the UIImageView's animatedImages to nil. I then release the NSMutableArray and recreate it. Is this correct?

Your question is meaningless without context, and the fact that you're asking it indicates a lack of familiarity with the Cocoa memory management rules.

Since we have been asked not to paraphrase them here, all I can suggest is that you review the documentation and, if you're still confused, post your code.

--Kyle Sluder


Regards,

John

Falling You - exploring the beauty of voice and sound
http://www.fallingyou.com



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to