• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [iPhone 3.0] correct way to release a UIImageView flip animation?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [iPhone 3.0] correct way to release a UIImageView flip animation?


  • Subject: Re: [iPhone 3.0] correct way to release a UIImageView flip animation?
  • From: John Michael Zorko <email@hidden>
  • Date: Sun, 09 Aug 2009 01:31:19 -0700


Kyle et al,

Wow, it's late ... I forgot some of the code in the last email -- here's all of it (still not much, no worries). I see the "program exited with signal:0" error after this code runs for awhile, and there's no backtrace.

On my view controller is:

- (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):

On my app delegate are:

- (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_ i.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)playAnimation:(UIView *)view
{
[self.animationView setAnimationDuration: [self.animationView.animationImages count] / 12];
self.animationView.animationRepeatCount = 1;
[view addSubview:self.animationView];
[self.animationView startAnimating];
}


- (void)preloadNextAnimation
{
    self.animationPreloaded = NO;

    // now preload the next ones ...

[self performSelectorInBackground:@selector(preloadAnimationThread) withObject:nil];
}


- (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 <email@hidden> 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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: [iPhone 3.0] correct way to release a UIImageView flip animation?
      • From: Dave Camp <email@hidden>
References: 
 >[iPhone 3.0] correct way to release a UIImageView flip animation? (From: John Michael Zorko <email@hidden>)
 >Re: [iPhone 3.0] correct way to release a UIImageView flip animation? (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: [iPhone 3.0] correct way to release a UIImageView flip animation?
  • Next by Date: Core Data - attribute to hold an array of strings
  • Previous by thread: Re: [iPhone 3.0] correct way to release a UIImageView flip animation?
  • Next by thread: Re: [iPhone 3.0] correct way to release a UIImageView flip animation?
  • Index(es):
    • Date
    • Thread