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

Mapping boolean values #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion RMMapper/RMMapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,13 @@ +(id)populateObject:(id)obj fromDictionary:(NSDictionary *)dict {
// Else, set value for key
else {
// If the value is basic type and is not array, parse it directly to obj
// http://stackoverflow.com/questions/3663266/kvc-string-conversion-not-working-for-bool-value
if (![value isKindOfClass:[NSArray class]]) {
[obj setValue:value forKey:property];
@try{ [obj setValue:value forKey:property];
}@catch(NSException * e){ // catch the exception if the value is a boolean
if ([e.name isEqualToString:NSInvalidArgumentException])
[obj setValue:@([value intValue]) forKey:property];
}
}

// If property is NSArray or NSMutableArray, and if user provides
Expand Down