There are definitely some overheads in generating objects. For a small number of objects, then using ObjC data structures is still suitable. If you have a large number of tuples, I would handle them in an array of C structures. Remember that Objective-C is actually just C. It is appropriate and common to use C constructors in Objective-C (to the point; learning where this point represents an important milestone in becoming a good Objective-C developer).
Usually for this type of data structure, I probably create a single Objective-C object that manages the entire collection. This way, external subscribers will see the Objective-C interface, but internal data will be stored in a more efficient C structure.
If you often access many tuples, my collection object will probably provide get methods similar to [NSArray getObjects:range:] . ObjC methods starting with "get" indicate that the first parameter is a pointer to be overwritten by this method. This is commonly used for high-performance C access to things controlled by an ObjC object.
This data structure is just like ObjC developers combine ObjC's elegance and maintainability with C performance and simplicity.
Rob napier
source share