我是Parse服务器的新手。
首先,我创建一个多维数组作为Parse服务器上的对象
let day1 = ["one", "two", "three", "four"]
let day2 = ["five", "six", "seven", "eight"]
let jan = [day1, day2]
let feb = [day1, day2]
let calendar = [jan, feb]
let user = PFUser()
user.username = userNameTextField.text
user.password = passwordTextField.text
user["Calendar"] = calendar
我想要的是能够执行PFUser查询并将日历[1] [0] [1]的值从“两个”更改为“零”。我已经阅读过Parse的文档,但是我对如何实现这一目标感到困惑。谢谢您的帮助!
最佳答案
这是完成我想做的事情的代码:
@IBOutlet weak var bedTimeTextField: UITextField!
var userCalendar = PFUser.current()?.object(forKey: "Calendar") as! Array<Array<Array<Any>>>
func setBedTime(int: Int) {
userCalendar[1][1][int] = 0
PFUser.current()?.setValue(userCalendar, forKey: "Calendar")
PFUser.current()?.saveInBackground()
}
@IBAction func cmonButton(_ sender: Any) {
if bedTimeTextField.text != "" {
let textFieldInt: Int? = Int(bedTimeTextField.text!)
setBedTime(int: textFieldInt!)
let userCalendar = PFUser.current()?.object(forKey: "Calendar") as! Array<Array<Array<Any>>>
print(userCalendar)
}
关于arrays - 在Swift中更改Array类型的PFUser对象中元素的值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48757795/