GitXplorerGitXplorer
b

NSDictionary-TypedAccessors

public
2 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
a39a21161f1971e8c648184c39f769b3f05b14e8

Adding the code

committed 12 years ago
Unverified
e5a664fb348a1e06560439c8ea13aa1fcb3daeaf

Updating readme

committed 12 years ago
Unverified
7e5b1342bbc271519de34d8de99d413578ae0c5a

Initial commit

bbryanoltman committed 12 years ago

README

The README file for this repository.

NSDictionary+TypedAccessors

This category builds upon NSDictionary's objectForKey: function to add more specific return types. If the value returned from objectForKey: is not of the desired type, this will attempt to coerce that value into the desired type.

I wrote this category because XML does not map directly to JSON. For example, most XML-to-JSON serializers would not convert XML collection with a single value into a JSON array. For example, this:

<omg-so-many-objects>
	<one-object>some-value</one-object>
</omg-so-many-objects>

gets converted to this:

omg-so-many-objects:some-value

instead of this:

omg-so-many-objects:[
	some-value
]

To solve this problem, you would use arrayForKey:, which would place some-value into an array.

All objects returned from functions in this category are autoreleasing, so this code works equally well with or without ARC.