是否可以使用空列(指针值)保存解析对象?
在我的代码中,如果用户未登录,我想将“userSubmitted”留空
var sendReport = PFObject(className:"UserReport")
sendReport["ReportReason"] = reason
sendReport["ReportedPhoto"] = reportedPhoto
if PFUser.currentUser() == nil
{
sendReport["UserSubmitted"] = nil
//sendReport["UserSubmitted"] = ""
} else {
sendReport["UserSubmitted"] = PFUser.currentUser()
}
sendReport.saveInBackgroundWithBlock {
[...]
}
在sendReport["UserSubmitted"] = nil
和sendReport["UserSubmitted"] = ""
[Error]: invalid type for key UserSubmitted, expected *_User, but got string (Code: 111, Version: 1.7.2)
答案 0 :(得分:1)
要取消设置属性,请使用removeObjectForKey ...
sendReport.removeObjectForKey("UserSubmitted")