Created
October 23, 2012 17:50
-
-
Save stupergenius/3940315 to your computer and use it in GitHub Desktop.
Plist Safe Objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define NILABLE(obj) ((obj) != nil ? (NSObject *)(obj) : (NSObject *)[NSNull null]) | |
#define FROM_NILABLE(key, dict) ([dict objectForKey:key] == [NSNull null) ? nil : [dict objectForKey:key] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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