iphone - How to copy objects, like AVAudioPlayer -


I wonder how some objects implement NCPOping is the third time in two weeks where I duplicate an existing object To do so, to go back to the disk without having to reload, or to recreate the object and set its settings.

Now do I have to duplicate an AVAudioPlayer sound? I want to play sound twice, without sound. Only time determines the playback location of the other playback.

I thought that class or subclass AVAudioPlayer can be easy and can implement copyWithZone However, AVAudioPlayer's internal hiding and I can not copy them easily.

Now I want the good old BlockMove (& var, & newVar, sizeof (varType));

How to duplicate the AVAudioPlayer sound or a UIView view?

Cause objects do not support NSCopying because it always has a link The object is not clear, and in particular, read more about what it means to 'copy the object'.

I will take a practical approach in this matter. If you need a bar frequency of AvAudioPlayer , then I would recommend it to:

  Evedia Player * Audio Player; // Be Honest AVAudioPlayer * Copyed Player = Faucet; CopiedPlayer = [[[Aviideo Player Allocation] Init Withdata: AudioplayerData] AutoCare];  

This does not mean a general solution because it does not handle all cases, this means that some uses depending on how you can eliminate the problem, depending on specific factors. . Breaks in the most notable example if the audio player was not started with the NSData object, but instead a url Some relatively safe assumptions about the variability of the data , and how to control those cases, AVAudioPlayer was coded Have not seen enough to see if this way The corner cases are behavioral documents).

If this is required to do a lot more, then you can probably combine another complex bit of code which encocaching is followed by a quick pass on the documentation Init object, through NSData or url and for instant objects, only two modes are changed to copy this information Is provided ... then the non-optimal deep copy encoding subclass For the reader to apply is left as an exercise. :)


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -