Hello,
I am getting an error when saving the object. Mind you it still saves it to the parse server, but the persistent error is annoying. I am unable to reproduce this error using any other struct other than my message struct:
ParseError code=-1 error=Invalid struct: No value associated with key CodingKeys(stringValue: “objectId”, intValue: nil) (“objectId”)
This is the struct:
struct Message: ParseObject {
var originalData: Data?
var objectId: String?
var createdAt: Date?
var updatedAt: Date?
var ACL: ParseACL?
var text: String?
var time: Date?
var read: Bool?
var senderName: String?
var senderID: String?
var spouseID: String?
var chatKey: String?
static func sampleMessage() -> Message {
return Message(text: "wow this is a sample messag", time: Date(), read: false, senderID: "b", spouseID: "a")
}
}
This is all I am trying to do:
let sentMessage = Message(text: text, time: Date(), read: false, senderName: usersProfile.name, senderID: usersProfile.id, spouseID: spouse?.id ?? "", chatKey: finalChatID)
sentMessage.save { result in
switch result {
case .success(_):
print("Saved Message")
case .failure(let error):
print(error)
print(error.message)
}
}
Subsequent error messages:
ParseError code=-1 error=Invalid struct: No value associated with key CodingKeys(stringValue: "objectId", intValue: nil) ("objectId").
Invalid struct: No value associated with key CodingKeys(stringValue: "objectId", intValue: nil) ("objectId").
One last observation is that when I refactored it to “Massage”, magically no error. Is there some sort of Message struct that already exists within that is causing this error?
ParseSwift Version: 4.2.0
Parse Server: 4.5
DB: MongoDB 3.6
Xcode: 13.2.1
MacOS: 12.3