Search code examples
ios5automatic-ref-countingstdstdvectorobjective-c++

storing AudioUnits in std::vector in iOS5 with ARC?


I'm building a little synth app/music toy which uses soundFonts. I have a varying number of interactive elements (call them BLOBS) which will have an "instrument" property - a reference to a Synth AudioUnit using one of a number of soundfonts.

I'd like this reference to be a simple int that I can use in order to access the appropriate AudioUnit to play a sound for a particular BLOB.

Is it legit/safe memory-wise in an iOS5 app using ARC to store these AudioUnits in a std::vector? I plan to populate the vector at startup and then just reference the contents as needed.

I define the vector as a property like this:

@property (nonatomic, assign) std::vector<AudioUnit> synthUnits;

Solution

  • AudioUnit is just a pointer so you can store it in a std::vector without any problems.

    Since Audio Unit Component Services is C interface, it doesn't participate in ARC at all.