On Mon, Oct 3, 2011 at 10:29 AM, Steve Sisak <sgs-li...@codewell.com> 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 (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