我在使用Parse-Server
的Swift iOS应用程序中有以下代码。
func theWiftFunction() {
PFCloud.callFunction(inBackground: "myCloudFunction",
withParameters: ["unitID": somePFObject.value(forKey: "objectId")!,
"userID": (PFUser.current()?.objectId)!]) {
(object: Any?, error: Error?) in
if error != nil {
if error?.localizedDescription == "NO-UNIT"
{print("The given unit has not been found for this user. This should not happen.")}
else {print("Error in \(#function)\n" + (error?.localizedDescription)!)}
return
}
// All is OK!!
};
.......
}
部分工作正常,但在某些情况下我收到此错误消息:
Error in theWiftFunction()
The data couldn’t be read because it isn’t in the correct format.
问题是:为什么数据,有时是正确的格式,有时不是?我该怎么做才能得到“正确的格式”?