Rightpoint / RZImport

Automatic importing of data from NSDictionary to Cocoa objects
Other
18 stars 6 forks source link

import bool primitive #30

Closed mr-fixit closed 8 years ago

mr-fixit commented 8 years ago

When importing to a boolean field, convert incoming strings and numbers to appropriate bool representations.

Incoming strings are converted via -[NSString boolValue], which currently is documented as:

This property is YES on encountering one of "Y", "y", "T", "t", or a digit 1-9—the method ignores any trailing characters. This property is NO if the receiver doesn’t begin with a valid decimal text representation of a number.

Incoming numbers are converted with -[NSNumber boolValue], which currently is documented as:

A 0 value always means NO, and any nonzero value is interpreted as YES.

KingOfBrian commented 8 years ago

Looks good to me. I don't think this will work for CoreData BOOL's that are exposed as NSNumbers, but that's a scenario that we won't be running into as much (primitive properties + swift). .

mr-fixit commented 8 years ago

@KingOfBrian it definitely doesn't work for NSNumbers! :¬(

KingOfBrian commented 8 years ago

Hey @jvisenti / @ZevEisenberg -- are you two good with this merging?