iphone - release sounds and memory manegment -
hello in application use code below handle , play sounds, want know if need release things or nothing do.
the code :
-(void) playnote: (nsstring*) note type: (nsstring*) type { cfurlref soundfileurlref; systemsoundid soundfileobject; cfbundleref mainbundle; mainbundle = cfbundlegetmainbundle (); // url sound file play soundfileurlref = cfbundlecopyresourceurl (mainbundle, (cfstringref)note, (cfstringref)type, null); // create system sound object representing sound file audioservicescreatesystemsoundid (soundfileurlref, &soundfileobject); audioservicesplaysystemsound (soundfileobject); }
thanks ,
you need call
audioservicesdisposesystemsoundid
to clean when done sound.
in header
@interface xyz { systemsoundid soundfileobject; };
in .m file, create init method (if dont have one):
-(id)init { if ( (self = [super init]) ) { audioservicescreatesystemsoundid (soundfileurlref, &soundfileobject); } return self; }
in dealloc
-(void)dealloc { audioservicedisposesystemsoundid(soundfileobject); [super dealloc]; }
you should declare soundfileurlref ivar
Comments
Post a Comment