If I abandon creating model objects which I only use to pass information and use NSDictionaries instead and have constant for keys in the same place where I am using the model, then does it have any impact on performance ?

For example: If I start passing NSDictionaries to custom cell's instead of creating Model classes for the cell, will it be fine if I am not providing any methods in the class of that model.

I have seen this a lot in iOS APIs like NSNotifications. I have rarely seen this in Java where collections are being used as an integral part of an API.


Object properties are generally at least an order of magnitude faster to access. Property access speed is also predictable whereas hash table access can take up to linear time.

Accessing property can be done by just accessing some memory address directly.

Accessing hash table requires you to get the hash value for the string (compute or take cached hash - both already take many instructions), then go through all the entries that match the bucket index and do expensive string comparisons until match is found or not found.

Still for many kinds of applications the hash table speed is not bad. In many language implementations object properties are hash table accesses (Ruby, CPython, PHP) and while it makes these languages extremely slow in an objective sense, they are still fast enough for many kinds of applications.

This is also assuming the implementation for NSDictionary is a hash table, any other implementation will be even slower.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.