Re: NSSound retain usage
Re: NSSound retain usage
- Subject: Re: NSSound retain usage
- From: Chris Kane <email@hidden>
- Date: Sat, 26 Jul 2003 20:12:36 -0700
On Monday, June 16, 2003, at 10:45, Chris Silverberg wrote:
A question regarding NSSound. When I use the 'play' method, will that
cause
the sound to retain itself for the duration of the play?
The reason I ask is that I'd like to be able to play a sound by simply
calling this:
[[NSSound soundNamed:@"wizbang"] play];
However, I could see this as being problematic. The sound is set to
auto-release because I'm using the soundNamed class method. So if the
sound
is still playing, what happens when the sound is released? But if
'play'
causes the sound to retain itself, then I dont have to worry about it
as it
would likely release itself after the sound completes(?)
Yes, the background operation, which is the playing, holds a reference
on the sound object. So that line of code is fine.
As a side point, I'm also curious about this issue in relation to
timers.
If I create a timer and schedule it, do I need to retain it just so I
can
release it later? Or is there a good way to create timers that will
release
themselves after they have been invalidated?
No (to the first question). If you schedule a timer, the run loop
holds onto it until the timer is invalidated.
Chris Kane
Cocoa Frameworks, Apple
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.