• 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: Object allocation problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Object allocation problem


  • Subject: Re: Object allocation problem
  • From: Paul Lynch <email@hidden>
  • Date: Fri, 17 Mar 2006 15:33:51 +0000


On 17 Mar 2006, at 15:28, Valerio Ferrucci wrote:

Hi,
perhaps I didn't understand very well the object allocation/ deallocation.
I want the poster from a movie to display in myApp.

That seems to be the problem.


BUT

If I uncomment the "[mov release]" line in the following code my App crashes.

Can someone explain me why?
How can I fix this?

- (NSImage*)getMoviePoster:(NSString*)moviePath
{
NSError *openError = nil;
QTMovie *mov = [QTMovie movieWithURL:[NSURL fileURLWithPath:moviePath] error:&openError];
NSImage *poster = [[mov posterImage] copy];


	// [mov release];

	return poster;
}

movieWithURL:error: returns an autoreleased object (the docs don't say so, but this is by naming convention).


The convention is that you should release objects that you have alloc/ init, or autorelease them if returned. Class methods starting with the class name (or a version of it) are always returned autoreleased.

Exercise for the reader: you might want to check what the status is of your poster return value.

Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Object allocation problem
      • From: Stig Brautaset <email@hidden>
References: 
 >Object allocation problem (From: Valerio Ferrucci <email@hidden>)

  • Prev by Date: Object allocation problem
  • Next by Date: Re: Object allocation problem
  • Previous by thread: Object allocation problem
  • Next by thread: Re: Object allocation problem
  • Index(es):
    • Date
    • Thread