Start a new topic
Answered

Entity with Date data type crashing is iOS

I defined an Entity in our iOS app with a date property as follows:


 

import Kinvey

class CordInvite : Entity {
 
    dynamic var team: String?
    dynamic var email: String?
    dynamic var invitedBy: String?
    dynamic var invitedOn: Date?
    dynamic var status: Bool = false
 
    override class func collectionName() -> String {
        return "invites"
 }
 
    override func propertyMapping(_ map: Map) {
 super.propertyMapping(map)
 
        team <- ("team", map["team"])
        email <- ("email", map["email"])
        invitedBy <- ("invitedBy", map["invitedBy"])
        invitedOn <- ("invitedOn", map["invitedOn"], KinveyDateTransform())
        status <- ("status", map["status"])
 }
}


Then at some function in our app I have the following code:


 let dataStore = DataStore<CordInvite>.collection(.sync)

            let invite = CordInvite()
            invite.team = user.team
            invite.email = email
            invite.invitedBy = user.userId
            invite.invitedOn = Date()
            invite.status = false

            dataStore.save(invite) { (invite, error) -> Void in
                if let error = error {
                    print(error.localizedDescription)
 }
            }
 
        dataStore.sync() { (count, invites, error) -> Void in
            if let error = error?.first {
 print(error.localizedDescription)
                errorAlert(in: self, baseMessage: "Error Saving Invites", error: error)
                return
 }
 }

 

 

The app crashes on the dataStore.sync() with the following exception:


Terminating app due to uncaught exception 'RLMException', reason: 'Invalid value '2017-10-27T20:53:46.219Z' for property 'CordInvite.invitedOn''


I can see however the data gets saved in the collection on Kinvey.  

 

Can someone tell us how to fix this?  

 

Thanks!


Best Answer

Andrew,


The issue with invalid date format was fixed in iOS SDK v3.9.1. In the last week, we have released our latest version of iOS SDK i.e. v3.10.0.


Updating to the latest SDK version should solve the issue. It's available for download at the following location:

https://devcenter.kinvey.com/ios/downloads#


Let me know if you face any issues even after updating to the latest version.


Thanks,

Pranav

Kinvey


Hello Andrew,


I see in our server logs that you are using the Kinvey iOS v3.7.1.  I would recommend that you upgrade to our latest version which is v3.10.0. While I cannot cite a specific fix in any releases since 3.7.1 that might fix this problem, it will help with debugging if you are on the latest release.


One of our iOS engineers, Pranav, will begin working this ticket and get back with you shortly with questions or suggestions.


Regards,


Billy Gee

Answer

Andrew,


The issue with invalid date format was fixed in iOS SDK v3.9.1. In the last week, we have released our latest version of iOS SDK i.e. v3.10.0.


Updating to the latest SDK version should solve the issue. It's available for download at the following location:

https://devcenter.kinvey.com/ios/downloads#


Let me know if you face any issues even after updating to the latest version.


Thanks,

Pranav

Kinvey

I'm using cocoapods so I did 'pod update' and got Kinvey's latest iOS SDK version 3.10.0.  There were some compile issues at first related to KinveyDateTransform but I was able to resolve them by applying the Xcode/Swift 4 suggested fix.  I have confirmed the issue I described above is now resolved.  Thanks!



Login or Signup to post a comment