Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support and options for parsing and packing NSData #5

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

csaftoiu
Copy link

@csaftoiu csaftoiu commented Oct 1, 2013

For my use case I need to ship around raw bytes that aren't utf8-strings. I added support for this.

The default behavior is almost the same: it attempts to parse the bytes into a utf8-string. However, if it fails, it'll raise an exception instead of either returning nil, not adding a key to a dictionary, or raising an exception when trying to add nil to an NSArray.

Additionally you can specify 3 different behaviors: try to parse as string but fallback on NSData, try to parse as string but fallback on NSNull, or always parse as NSData.

…ings. this was necessary in my application.

I wasn't sure what the desired behavior should be so I left in some options - see the readme for descriptions.
by default, it will return an NSNull on failing to decode a string. i felt this was as close to the original behavior and thus most backwards compatible, but really i'd prefer the default to be an exception. i can change this if need be
@tomtaylor
Copy link

Any chance of getting this merged into master? It's a significant improvement, and it feels right that this is officially supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants