I am trying to use RestKit in my Swift based project. It seems like I can't use Swift primitive data types such as Int, Double, Bool, etc., Except for String, Array and Dictionaries (which seems to be due to the fact that they are duty-free connected to NSString. NSArray and NSDictionary)
With objective-c, I could define properties in my objects as primitive data types as properties that are assigned. In Swift, I can only use objects (String, NSNumber, Array, Dictionary), otherwise the application will fail using "setValue: forUndefinedKey: this class is not suitable for encoding the key for the aBool key".
Example: Here is how my object will look in Objective-C:
@interface TestObject : NSObject @property (strong, nonatomic) NSString *aString; @property (assign, nonatomic) BOOL aBool; @property (assign, nonatomic) CGFloat aFloat; @end
and the "equivalent" in Swift:
class TestObject:NSObject { var aString:NSString? var aBool:Bool? var aFloat:Double? }
What happens, and when I understand WHY it crashes, I would like to know if there is another workaround than using NSNumber for Booleans, Integer and Floats, just like it works in Objective-C?
(If any of the RestKit developers reads this: First of all, thanks for your work, and then: Are there any plans for Swift support / port for Swift?)