aryaxt / OCMapper

Objective-C library to easily map NSDictionary to model objects, works perfectly with Alamofire. ObjectMapper works similar to GSON
MIT License
347 stars 45 forks source link

How to handle boolean properties? #35

Closed maml closed 9 years ago

maml commented 9 years ago

I have an object with a boolean property but it never gets set, it's always nil. How should I declare this property?

MyObject {
  var id: NSNumber?
  var userId: NSNumber?
  var state: String?
  var active: Bool?
}
aryaxt commented 9 years ago

Just like core data. Use nsnumber for the property. Then call boolValue to get its value as a Boolean. Also the class must inherit from nsobject not quite sure how it's working right now without it, look at the samples for more info

maml commented 9 years ago

Great, thx!

stevemu commented 9 years ago

This is great, thank you for the fix!