使用空指针列解析保存对象

时间:2015-05-21 00:39:58

标签: swift parse-platform

是否可以使用空列(指针值)保存解析对象?

在我的代码中,如果用户未登录,我想将“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"] = nilsendReport["UserSubmitted"] = ""

处崩溃
[Error]: invalid type for key UserSubmitted, expected *_User, but got string (Code: 111, Version: 1.7.2)

1 个答案:

答案 0 :(得分:1)

要取消设置属性,请使用removeObjectForKey ...

sendReport.removeObjectForKey("UserSubmitted")