我对此进行了广泛的研究。前几天听到有关 Parse 的消息后,我一直在玩弄将 Kinvey 用于我的 BaaS。我正在尝试保存对象,但收到与 KCSPersistable 相关的错误。
class Event : NSObject{
var entityId: String? //Kinvey entity _id
var name: String?
var date: NSDate?
var location: String?
var metadata: KCSMetadata? //Kinvey metadata, optional
}
func hostToKinveyPropertyMapping() -> [NSObject : AnyObject]! {
return [
"entityId" : KCSEntityKeyId, //the required _id field
"name" : "name",
"date" : "date",
"location" : "location",
"metadata" : KCSEntityKeyMetadata //optional _metadata field
]
}
由于超类,Swift 将其称为 NSObject 的冗余。我删除了 KCSPersistable 声明,代码将成功构建,但是现在我收到以下错误:
'Object "<KinveyPractive.Event: 0x7fed18d484c0>" of type "KinveyPractive.Event" does not implement 'hostToKinveyPropertyMapping', a required 'KCSPersistable' method for saving the object to the backend'
我遇到了一个问题循环。如果我删除 KCSPersistable,Xcode 会要求它。但是,如果我离开它,Xcode 将无法编译。