• 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: Retain/Release and Properties clarification
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Retain/Release and Properties clarification


  • Subject: Re: Retain/Release and Properties clarification
  • From: John Tsombakos <email@hidden>
  • Date: Mon, 03 Oct 2011 11:14:13 -0400

On Mon, Oct 3, 2011 at 10:29 AM, Steve Sisak <email@hidden> wrote:
>> At 10:14 AM -0400 10/3/11, John Tsombakos wrote:
>> @interface AudioPlayerViewController : UIViewController {
>> AVAudioPlayer *audioPlayer;
>> }
>> @property (retain) AVAudioPlayer *audioPlayer;
>>
>> In the .m file:
>> @synthesize audioPlayer;
>> in viewDidLoad:
>> audioPlayer = [self getSoundFile:"soundfile.wav"];
>
> You got close with:
>
>> (side note... should that be self.audioPlayer = ... ? I keep getting
>> confused with accessors vs. ivars too ;) )
>
> You do, indeed want:
>
> self.audioPlayer = [self getSoundFile:"soundfile.wav"];
>
> or
>
> [self setAudioPlayer = [self getSoundFile:"soundfile.wav"]];
>
> Without the self. you're bypassing the setter (which is responsible for
> retain/release) and just setting the instance variable directly. Therefore
> there's no retain.

Yeah, as I was typing out the message, I had the realization that I
should probably be using the self. and that was most likely the cause
of my problems. I couldn't try it, because my system is at home ;) I
will give it a try later (and will also change to use the underscore
ivar names too - I had done that previously, but...well, didn't this
time.)

Funny how you think you got the concepts all sorted out, and I get it,
really, but when actually typing some code, it all gets confusing ;)

Thanks!
_______________________________________________

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: Retain/Release and Properties clarification
      • From: Charles Srstka <email@hidden>
References: 
 >Retain/Release and Properties clarification (From: John Tsombakos <email@hidden>)

  • Prev by Date: Re: Retain/Release and Properties clarification
  • Next by Date: spin_lock$VARIANT$mp in Sketch
  • Previous by thread: Re: Retain/Release and Properties clarification
  • Next by thread: Re: Retain/Release and Properties clarification
  • Index(es):
    • Date
    • Thread