gpt4 book ai didi

swift - 看不到我在 Parse 中发布的消息

转载 作者:行者123 更新时间:2023-11-30 10:10:59 26 4
gpt4 key购买 nike

我正在创建一个 yik yak 克隆,但我似乎看不到我在 Parse 上的 textField(string) 中发布的消息。我的代码中是否有什么错误导致它没有显示在 Parse 上?

  @IBAction func postPressed(sender: AnyObject) {


if(currLocation != nil){
let testObj = PFObject(className: "BubbleTest")

testObj["userName"] = PFUser.currentUser()?.username
//testObj["profileName"] = PFUser.valueForKey("profileName") as! String
//testObj["photo"] = PFUser.currentUser()?.valueForKey("photo") as! PFFile
testObj["textField"] = self.textField.text
testObj["location"] = PFGeoPoint(latitude: currLocation!.latitude , longitude: currLocation!.longitude)
testObj["count"] = 0
testObj["replies"] = 0
testObj.saveInBackground()


self.dismissViewControllerAnimated(true, completion: nil)
}
else {
alert()
}

最佳答案

您看不到任何内容的原因是您将其发布到错误的类中。根据图片BubbleTest是类名而不是YikYakTest

替换此行

   let testObj = PFObject(className: "YikYakTest")

let testObj = PFObject(className: "BubbleTest")

您的代码应如下所示:

注意使用 saveInBackgroundWithBlock 方法,以便您可以检查保存时是否有错误

 let testObj = PFObject(className: "BubbleTest")
let username = PFUser.currentUser()?.username
testObj["userName"] = username
testObj["textField"] = self.textField.text
testObj["Location"] = PFGeoPoint(latitude:currLocation.latitude , longitude: currLocation.longitude)
testObj["count"] = 0
testObj["replies"] = 0
testObj.saveInBackgroundWithBlock { (success:Bool, error :NSError?) -> Void in
if error == nil
{
print("detail is saved")
self.dismissViewControllerAnimated(true, completion: nil)
}
else
{
print("error")
}
}

当您保存PFGeopoint坐标时,将其保存到Location列而不是location

关于swift - 看不到我在 Parse 中发布的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33086704/

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