Skip to content

Instantly share code, notes, and snippets.


kean/safe_cast.m Secret

Created Jul 2, 2017
What would you like to do?
#define safe_cast(TYPE, object) \
({ \
TYPE *dyn_cast_object = (TYPE*)(object); \
[dyn_cast_object isKindOfClass:[TYPE class]] ? dyn_cast_object : nil; \
entity.ID = safe_cast(NSString, data[@"uid"]);
entity.firstName = safe_cast(NSString, data[@"first_name"]);
entity.lastName = safe_cast(NSString, data[@"last_name"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment