I want to keep a mutable collection of CGImageRefs. Do I need to wrap them in NSValue, and if so how do I wrap and unwrap them properly? Can I get away with using a C array? If so how do I construct it and how do I add elements to it later? Is it significantly more costly to use UIImages instead of CGImageRefs as the elements of the collection?
Share
Getting the CGImageRef out of an UIImage via image.CGImage can be costly. From the documentation:
If you feel comfortable with mixing C++ and Objective-C, you can use a std::vector for storing the CGImageRef. Rename your source file from .m to .mm and try this:
If you want to keep the vector as a member of a Objective-C class, you should allocate it on the heap, not the stack:
Header file:
and in the implementation file: