所以我是使用Parse的新手,并且在通过后端发布消息时遇到了一些问题。我能够设置一个用户帐户,但是当我尝试提交帖子时,我收到一条错误,上面写着..."致命错误:在打开一个可选值时意外发现nil" ...?
这是我的代码:
class ComposeViewController: UIViewController {
@IBOutlet var travelTextView: UITextView!
@IBOutlet var charRemainingLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func sendPost(sender: AnyObject) {
var travelPost:PFObject = PFObject(className: "travelposts")
travelPost["content"] = travelTextView.text
travelPost["poster"] = PFUser.currentUser()
travelPost.saveInBackgroundWithTarget(nil, selector: nil)
self.navigationController?.popToRootViewControllerAnimated(true)
}
答案 0 :(得分:0)
你不能为选择器传递nil。
travelPost.saveInBackgroundWithTarget(nil, selector: nil);
这样做只是保存对象。
travelPost.saveInBackground();
但是您希望在保存对象时收到通知