While I do prefer to use JSON, instead of XML. I use to prefer it, but for the wrong reasons. Well, not wrong, but you can always improve right? So why do I love it?
– Lighter than XML
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:myJsonData options:kNilOptions error:&error];
Well the first is really nice, but it doesn’t really help us out, at least directly. The second is just glorious. You get a
NSDictionary, that you can use across all your app, with one single line. What’s the catch? In terms of visibility is just wrong. I know I have my data there, but does the next guy that is going to support my app knows that? I can leave some comments…. I promise.. Instead, just create a class to hold that data, and give it some meaning. What I would recomment is something like this:
It is boring, but it gives visibility, helps maintenance, and gives meaning to your data.