Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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