Start a new topic

Saving KCSUser as a property

I have a class call Newsfeed and every newsfeed object contains a variable called author of type KCSUser. whenever I try creating a user. I get the following exception

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (KCSUser)'

This is my Newsfeed Class.  I'm not sure why i'm getting this exception cause according to documentation, I should be able to save a KCSUser.

class Newsfeed: NSObject {

var entityId: String?

var authorImageUrl: String?

var authorFullName: String?

var authorUserId: String?

var author: KCSUser?

var attachments: [String]?

var attachmentType: Int = 0

var viewCount: Int = 0

var message: String?

var metadata: KCSMetadata?

override func hostToKinveyPropertyMapping() -> [NSObject : AnyObject]! {

return [

"entityId" : KCSEntityKeyId,

"authorImageUrl" : "authorImageUrl",

"authorFullName" : "authorFullName",

"authorUserId" : "authorUserId",

"author" : "author",

"attachments" : "attachments",

"attachmentType": "attachmentType",

"viewCount" : "viewCount",

"message" : "message",

"metadata" : KCSEntityKeyMetadata



static override func kinveyPropertyToCollectionMapping() -> [NSObject : AnyObject]! {

return [

"author" : KCSUserCollectionName,




Hello all,

We have released an update to the iOS library (1.40.5) which is available over here:


1 person likes this

Also, if there is an earlier library that I can use (proven to be working) in the mean time, please let me know. 

@Damien, any updates on the fix?


Our development sprint wraps up this coming Wednesday, so I would anticipate seeing it by close of business on Wednesday or sooner.  I will update this thread when we release the update.


1 person likes this

@Damien we're counting on you guys....  we're still waiting for the updated SDK

1 person likes this

Require this for me app as well

Hey Damien, thank you for looking into this.

Steeven, Addy,

At this time this is being looked at as a bug in our codebase.   We apologize for the inconvenience that this is clearly causing and will hopefully release an updated SDK in the next few days to address this.


2 people like this

Exactly the same problem! Someone please help, this stuff was so easy with Parse and worked instantly on Backendless, why won't it work here?

I figured out why I was getting this issue. I was using KCSAppdataStore instead of KCSLinkedAppdataStore after using KCSLinkedAppdataStore, i'm getting similar error but for KCSKinveyRef.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (KCSKinveyRef)'

this is the saving code.

class func saveObject(collectionName collectionName: String,

collectionClass: AnyClass,

collectionObj: AnyObject,

linkedAppDataSotre: Bool,

saveBlock: SaveBlock,

progressBlock: ProgressBlock?) {

var store: KCSAppdataStore

let collection = KCSCollection(fromString: collectionName, ofClass: collectionClass.self)

if linkedAppDataSotre == true {

store = KCSLinkedAppdataStore(collection: collection, options: nil)

} else {

store = KCSAppdataStore(collection: collection, options: nil)


store.saveObject(collectionObj, withCompletionBlock: { (response, error) -> Void in

saveBlock(response: response, error: error)

}) { (response, percentCompleted) -> Void in

if let progress = progressBlock {

progress(response: response, percentCompleted: percentCompleted)




Can someone help please, because I really need to be able to have relational model.  Right now i'm stuck and can't do much without resolving this issue.

3 people like this
Login or Signup to post a comment