• 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: Releasing by reference
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Releasing by reference


  • Subject: Re: Releasing by reference
  • From: j o a r <email@hidden>
  • Date: Wed, 1 Aug 2007 15:54:02 +0200


On 1 aug 2007, at 15.16, email@hidden wrote:

The implementation is something like this:

Object in class A: [QTMovie movieWithFile:@"/path/to/mov" error:err]

Sent as parameter aMovie to class B:

static QTMovie *mov = nil;

- (QTMovieView *)openMovie: (QTMovie *) aMovie {
mov = aMovie;
}

- dealloc {
if ( mov != nil ) {
[mov release];
mov = nil;
 }
}


1) You should not release something that you don't own, and as you neither create or retain the movie, you don't own it. That is probably in error however, and I expect that you should retain it before assigning it to your variable in B.

2) Why are you using a static variable? An instance variable seems, at a glance, more appropriate - especially as you release it in dealloc.

j o a r


Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >Releasing by reference (From: email@hidden)
 >Re: Releasing by reference (From: Stephane Sudre <email@hidden>)
 >Re: Releasing by reference (From: email@hidden)

  • Prev by Date: Re: Releasing by reference
  • Next by Date: Re: Releasing by reference
  • Previous by thread: Re: Releasing by reference
  • Next by thread: Re: Releasing by reference
  • Index(es):
    • Date
    • Thread