I am trying to use RestKit in my Swift based project. I do not seem to be able to use Swift primitive data types, like Int, Double, Bool and so on, except for String, Array and Dictionaries (which presumably is due to the fact, that they are toll-free bridged to NSString, NSArray and NSDictionary)
With objective-c I could define properties in my objects as being primitive datatypes as properties, which are assigned. In Swift I can only use objects (String, NSNumber, Array, Dictionary), otherwise the app crashes with "setValue:forUndefinedKey: this class is not key value coding-compliant for the key aBool".
Example: Here's how my object would look like 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?
}
That crashes and while I do understand WHY it crashes, I would like to know, whether there is another workaround, than using NSNumber for Booleans, Integers and Floats, in the same way it works in Objective-C?
(If any of the RestKit developers are reading this: First of all thanks for your work and then: Are there any plans regarding Swift support / port to Swift?)