https://github.com/mosheberman/arraydictarray
A pair of categories that can encode an NSArray as an NSDictionary and back again.
https://github.com/mosheberman/arraydictarray
Last synced: 2 months ago
JSON representation
A pair of categories that can encode an NSArray as an NSDictionary and back again.
- Host: GitHub
- URL: https://github.com/mosheberman/arraydictarray
- Owner: MosheBerman
- Created: 2013-05-29T04:27:53.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2013-05-29T04:38:33.000Z (about 13 years ago)
- Last Synced: 2026-01-01T18:39:44.853Z (6 months ago)
- Language: Objective-C
- Size: 125 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ArrayDictArray
==============
A pair of categories that can encode an NSArray as an NSDictionary and back again.
Setting It Up:
---
Just drop the categories folder into your project and then `#import ArrayDictArray.h` where you want to use it.
What it does:
---
Once you've imported the header, you'll find that `NSArray` now has a method called `dictionary` and that `NSDictionary` has a method called `array`.
NSArray to NSDictionary
---
The `dictionary` takes the recieving `NSArray` instance and copies the objects in it into a dictionary. Each item's index becomes the key. Keys in the new dictionary are instances of `NSNumber`. An instance of `NSMutableDictionary` is returned.
NSDictionary to NSArray
---
The `array` method takes the recieving `NSDictionary` instance and copies the objects in it into an array. This assumes that the dictionary's keys are sequential `NSNumber` objects, presumably the result of calling `dictionary` on an `NSArray`. The behavior for any other kind of key is undefined. An instance of `NSMutableArray` is returned.