Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
A question about NSDictionary
So, I'm just thinking out loud and I'd like to understand something a little more.
If storing structured data in a dictionary isn't considered practical because to access its value we must first know its key, why is it that we're still storing/accessing information in dictionaries?
I'm not questioning the usefulness of dictionaries but more as to why we are told not to store structured data in them given we're accessing remote data that's already stored in a dictionary.
I understand that the "Using a Custom Class" section is to teach us about the usefulness of custom classes and gets us to practice using them as well as adapting our thought process to include them as we build out our applications, but I'm just curious as to why this statement in my second paragraph is made yet inherently we use dictionaries to store data.
Amit BijlaniTreehouse Guest Teacher
NSDictionary is a collection just like an array and it can be useful in a variety of situations. There is no hard and fast rule to create a custom class, however, if you are using a dictionary throughout your app to structure data then you are better off with a custom class. If it is a one-off use case or you need to pass data around then a dictionary is your best friend.