Kinvey: Object not saving due to error: Cannot map 'X', a non-existant property
Kinvey: Object not saving due to error: Cannot map 'X', a non-existant property
我是从 Parse 转移到 Kinvey 的小组的一员。但是,我无法保存对象。我收到错误:
error : Error Domain=KCSAppDataErrorDomain Code=60102 "Entity does not have property 'NumberOfPlayers' as specified in hostToKinveyPropertyMapping" UserInfo={NSLocalizedRecoverySuggestion=Check the hostToKinveyPropertyMapping for typos and errors., NSLocalizedDescription=Entity does not have property 'NumberOfPlayers' as specified in hostToKinveyPropertyMapping, NSLocalizedFailureReason=Cannot map 'NumberOfPlayers', a non-existant property}
我已经按照他们网站上的指南进行操作:
http://devcenter.kinvey.com/ios/guides/datastore#create
我的代码:
class Event: NSObject {
var objectId:String?
var Sport:Int?
var NumberOfPlayers:Int?
var SkillLevel:Int?
var Date:NSDate?
var Time:NSDate?
var Competitive:NSNumber?
override func hostToKinveyPropertyMapping() -> [NSObject : AnyObject]! {
return [
"objectId" : KCSEntityKeyId,
"Sport" : "Sport",
"NumberOfPlayers" : "NumberOfPlayers",
"SkillLevel" : "SkillLevel",
"Date" : "Date",
"Time" : "Time",
"Competitive" : "Competitive",
]
}
}
节省:
let event = Event()
event.Sport = 0
event.NumberOfPlayers = playerQuantity
event.SkillLevel = skillLevel
event.Date = date
event.Time = time
event.Competitive = competitive
let collection = KCSCollection(fromString: "Event", ofClass: Event.self)
let store = KCSAppdataStore(collection: collection, options: nil)
// let store = KCSAppdataStore.storeWithOptions([
// KCSStoreKeyCollectionName : "Event",
// KCSStoreKeyCollectionTemplateClass : Event.self
// ])
store.saveObject(event, withCompletionBlock: { (objects, error) -> Void in
if error != nil { print("error : \(error)"); return }
print("saved objects")
}, withProgressBlock: nil)
两种创建 DataStore 的方法均无效。他们都return同样的错误。
我还检查了 AppId
和 AppSecret
是否正确。我可以 sign up
用户和 login
好吧,我只是不能保存数据。
有什么想法吗?
任何数字类型都应归类为 NSNumbers 而不是 Ints
我是从 Parse 转移到 Kinvey 的小组的一员。但是,我无法保存对象。我收到错误:
error : Error Domain=KCSAppDataErrorDomain Code=60102 "Entity does not have property 'NumberOfPlayers' as specified in hostToKinveyPropertyMapping" UserInfo={NSLocalizedRecoverySuggestion=Check the hostToKinveyPropertyMapping for typos and errors., NSLocalizedDescription=Entity does not have property 'NumberOfPlayers' as specified in hostToKinveyPropertyMapping, NSLocalizedFailureReason=Cannot map 'NumberOfPlayers', a non-existant property}
我已经按照他们网站上的指南进行操作: http://devcenter.kinvey.com/ios/guides/datastore#create
我的代码:
class Event: NSObject {
var objectId:String?
var Sport:Int?
var NumberOfPlayers:Int?
var SkillLevel:Int?
var Date:NSDate?
var Time:NSDate?
var Competitive:NSNumber?
override func hostToKinveyPropertyMapping() -> [NSObject : AnyObject]! {
return [
"objectId" : KCSEntityKeyId,
"Sport" : "Sport",
"NumberOfPlayers" : "NumberOfPlayers",
"SkillLevel" : "SkillLevel",
"Date" : "Date",
"Time" : "Time",
"Competitive" : "Competitive",
]
}
}
节省:
let event = Event()
event.Sport = 0
event.NumberOfPlayers = playerQuantity
event.SkillLevel = skillLevel
event.Date = date
event.Time = time
event.Competitive = competitive
let collection = KCSCollection(fromString: "Event", ofClass: Event.self)
let store = KCSAppdataStore(collection: collection, options: nil)
// let store = KCSAppdataStore.storeWithOptions([
// KCSStoreKeyCollectionName : "Event",
// KCSStoreKeyCollectionTemplateClass : Event.self
// ])
store.saveObject(event, withCompletionBlock: { (objects, error) -> Void in
if error != nil { print("error : \(error)"); return }
print("saved objects")
}, withProgressBlock: nil)
两种创建 DataStore 的方法均无效。他们都return同样的错误。
我还检查了 AppId
和 AppSecret
是否正确。我可以 sign up
用户和 login
好吧,我只是不能保存数据。
有什么想法吗?
任何数字类型都应归类为 NSNumbers 而不是 Ints