Are there any more efficient data types in o开发者_开发百科bjective c that implements structs, or is the C struct, even though used in objective c more efficient?
The most efficient storage mechanism is one that gets your app to market before your competition while offering a decent user experience.
Are you really working with so much data that you have measured a performance hit that matters?
For plain old structured, non-persisted, data, I use Objective-C classes with a series of @property
declarations for the various fields. Doing this allows memory management to remain encapsulated with the data and I can easily refactor this into a full-blown class with persistence and/or business logic later.
For persisted data, I use Core Data for just about everything but pure archival of object graphs.
If you just want a data only record (i.e. no methods) the C struct is the most efficient in terms of space and speed.
However, Objective-C objects are implemented as C structs under the hood, so raw member access is as fast as for a C struct. People tend not to use that because the advantages of using accessors outweigh the speed penalty in most situations.
精彩评论