Start a new topic
Answered

NSLocalizedDescription=Entity does not have property 'sport' as specified in hostToKinveyPropertyMapping, NSLocalizedFailureReason=Cannot map 'X', a non-existant property

Hey guys,


I'm having an issue saving an object, getting the error: 


error : Error Domain=KCSAppDataErrorDomain Code=60102 "Entity does not have property 'sport' as specified in hostToKinveyPropertyMapping" UserInfo={NSLocalizedRecoverySuggestion=Check the hostToKinveyPropertyMapping for typos and errors., NSLocalizedDescription=Entity does not have property 'sport' as specified in hostToKinveyPropertyMapping, NSLocalizedFailureReason=Cannot map 'sport', a non-existant property}


As I understand it, the collection doesn't have a column "sport." The only problem is that is does. Here is my code:


 Class:

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"
        ]
    }
}

 Saving : 

 

func GameSetUpView_didTapFindPlayersButton(playerQuantity: Int, skillLevel: Int, date: NSDate, time: NSDate, competitive:Bool) {
        let event = Event()
        event.sport = 0
        event.numberOfPlayers = playerQuantity
        event.skillLevel = skillLevel
        event.date = date
        event.time = time
        event.competitive = competitive
        
        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)
    }

 

And my dashboard:


Any ideas?


Best Answer

FIXED: You cannot use Int types. Instead, any number types should be NSNumber


Answer

FIXED: You cannot use Int types. Instead, any number types should be NSNumber

I added a sample object in via the dashboard, however I still can't save objects. Getting the same error

In the "Saving" part, sport is set to 0. Do I have to do anything else before saving? The error is displayed instantaneously, leading me to think that the error is caused due to some error in the app.

Do either of those "sports" have values in them?  The databrowser isn't an accurate representation of what's happening.   If you didn't save any values to that "column" (it's actually a disservice calling it a column, because it's Mongo data, and it's not a column, it's just data) then you still can't query on it.



Your code looks about right otherwise.

Login or Signup to post a comment