iphone - Trying to fix memory leak using AVAudioPlayer -


In an attempt to fix memory leak, I am trying to apply this code in my .m file:

  Aviideo Player * Audio Player; - (AviadioPlayer *) Audio PlayerWind contentoff file: (NSSTING *) path {NSDTA * Audioteta = [NSDATA data content content: path]; Aviideo player * player = [aviideo player]]; If ([player initWithData: audiotada error: NULL]) [[Player Autorequez]; } And {[Player release]; Player = zero; } Returning player; }  

Then try to call it via:

  [audio players audio playerwind contentofffile: [NSString stringWithFormat: @ "% @ / knock_knock. Wav ", [[NSBundle main bundle] resource path]]];  

The header file contains:

  - (aviadio player) * audio playerwidgetofffile: (NSString *) path; Compiled with a warning: AVAudioPlayer can not respond to 'audio player content offfile' ('to return the message' id 'without matching signature and arguments will be accepted as' ...'  

Every time I am getting this language, I run the stuff like this that I am trying to understand. Anybody can be able to help? As always thanks, thanks in advance. / P>

live ...

  AVAudioPlayer * player = [AVAudioPlayer alloc];   

Because you have been left with an unpublished object and you forget to input it later. In normal circumstances, you are supposed to send always The method for a new allocated object ... In other words, the correct way is to call + alloc and a "sentence" in -init.

Second, the next AviPlayer -Inte Withdata: Error: Return Nile You can not release it because you can leave the message in the end-autore with zero conference, if any object is not included, then you should leave it yourself and return it to zero. What is AVAudioPlayer if it can not read or recognize audio data. In other words, do not try to release it yourself. In this way, a simplified version of your method goes like this:

  - (AVAudioPlayer *) audioplayerwithContentsOfFile: (NSString *) path {NSDT * Audioteta = [Nsdata datawith content offfile: path]; Return [[[AviPro Player Alok] initWithData: AudioData Error: NULL] Autoreclass]; }  

Make sure that you send messages to the appropriate class because AVAudioPlayer does not apply to your -OudioPlayerWith ContentsAffFile: method. See where its definition and implementation can go.

  @interface SomeClass: NSObject ... - (AVAudioPlayer *) Audio PlayerWind Contentoff file: (NSString *) path; @end  

Defined above- Audio PlayerWindOffFileFile: For Class Classes Some Classes, You Should Send Messages To Some Causes Of Examples, Not AVIADIO Player If You Are For The AVAudioPlayer Category If you want to define the method, then do it instead:

  @interface AVAudioPlayer (MyExtensions) + (AVAudioPlayer *) Audio Player: Various ResourcesOffuffle: (NSString *) path; @Ap @Iplimentation Evolution Player (MyExtension) + (AviPlayer Player) Audio Player with Contentofffile: (NSSTING *) Path {NSDTA * Audiodeeta = [NSDATA DataWith ContentOffFile: Path]; Return [[[AviPro Player Alok] initWithData: AudioData Error: NULL] Autoreclass]; } @end  

To use it:

  [Avidia Player Playerswind contentoff file: [[NSBindal main bundle] Pathforce resources: @ "knock_knock" type Key: @ "Wave"]];  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -