gpt4 book ai didi

ios - “NSInvalidArgumentException”,原因 : 'Can' t use nil for keys or values on PFObject. 使用 NSNull 作为值。 (以前的答案不修复它)

转载 作者:行者123 更新时间:2023-11-29 02:20:55 25 4
gpt4 key购买 nike

我有我的应用程序,用户可以在其中发布内容,其他用户可以对其进行评论,然后,我使用“SendYourOpinion”方法来存储它

 - (IBAction)SendYourOpinion:(id)sender {

PFObject *opinion = [PFObject objectWithClassName:@"Opinions"];
opinion[@"content"] = self.txtFieldOpinion.text;
opinion[@"userId"] = [PFUser currentUser];
[opinion saveInBackground];

}

而且出现了题目中的错误,然后我看了之前的回答,我的问题还是没有解决

最佳答案

self.txtFieldOpinion.text[PFUser currentUser]nil

您需要检查 nil 并改为分配一个对象。您不能将 nil 指定为值(如您收到的错误消息中所述)。

    PFObject *opinion = [PFObject objectWithClassName:@"Opinions"];
opinion[@"content"] = self.txtFieldOpinion.text ? self.txtFieldOpinion.text : [NSNull null];
opinion[@"userId"] = [PFUser currentUser] ? [PFUser currentUser] : [NSNull null];
[opinion saveInBackground];

关于ios - “NSInvalidArgumentException”,原因 : 'Can' t use nil for keys or values on PFObject. 使用 NSNull 作为值。 (以前的答案不修复它),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28152237/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com