Skip to content

Instantly share code, notes, and snippets.

@stupergenius
Created October 23, 2012 17:50
Show Gist options
  • Save stupergenius/3940315 to your computer and use it in GitHub Desktop.
Save stupergenius/3940315 to your computer and use it in GitHub Desktop.
Plist Safe Objects
#define NILABLE(obj) ((obj) != nil ? (NSObject *)(obj) : (NSObject *)[NSNull null])
#define FROM_NILABLE(key, dict) ([dict objectForKey:key] == [NSNull null) ? nil : [dict objectForKey:key]
@stupergenius
Copy link
Author

I have not tried FROM_NILABLE, but I assume it would work, either returning nil in the case that the key wasn't in the dict or that the value in the dict was [NSNull null], and otherwise the object in the dict.

NILABLE is from https://github.com/phonegap/phonegap-plugins/blob/master/iOS/InAppPurchaseManager/InAppPurchaseManager.m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment