尝试将变量保存为自定义解析对象 (UserRecipe) 的列表并将它们打印到 xcode 控制台
Trying to save variable as list of custom parse object (UserRecipe) and print them to the xcode console
我正在尝试使用 ios 解析 SDK (1.9.1) 在 xcode 中做一件真正简单的事情。我正在尝试创建一个变量来存储我在名为 UserRecipe
的解析自定义对象中的所有数据
这是我的解析设置的样子
下面是我的代码:
import UIKit
import Parse
//import ParseFacebookUtilsV4
import FBSDKCoreKit
import FBSDKLoginKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let userRecipe = PFObject(className: "UserRecipe")
print(userRecipe)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
在我的 xcode 控制台日志中,这是我返回的内容:
它似乎没有在 UserRecipe class 解析中返回我的 5 个食谱对象。谁能帮我解决这个问题?在此先感谢您的帮助
发布的代码只是在本地创建一个新对象并将其记录到控制台。为了查看存储在远程数据中的对象,您需要查询它们。
Read all about it here,但总结一下...
var query = PFQuery(className:"UserRecipe")
query.findObjectsInBackgroundWithBlock {
(objects: [PFObject]?, error: NSError?) -> Void in
if error == nil {
if let objects = objects {
for object in objects {
print(object["recipeName"])
}
}
} else {
print("Error: \(error!) \(error!.userInfo)")
}
}
我正在尝试使用 ios 解析 SDK (1.9.1) 在 xcode 中做一件真正简单的事情。我正在尝试创建一个变量来存储我在名为 UserRecipe
的解析自定义对象中的所有数据这是我的解析设置的样子
下面是我的代码:
import UIKit
import Parse
//import ParseFacebookUtilsV4
import FBSDKCoreKit
import FBSDKLoginKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let userRecipe = PFObject(className: "UserRecipe")
print(userRecipe)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
在我的 xcode 控制台日志中,这是我返回的内容:
它似乎没有在 UserRecipe class 解析中返回我的 5 个食谱对象。谁能帮我解决这个问题?在此先感谢您的帮助
发布的代码只是在本地创建一个新对象并将其记录到控制台。为了查看存储在远程数据中的对象,您需要查询它们。
Read all about it here,但总结一下...
var query = PFQuery(className:"UserRecipe")
query.findObjectsInBackgroundWithBlock {
(objects: [PFObject]?, error: NSError?) -> Void in
if error == nil {
if let objects = objects {
for object in objects {
print(object["recipeName"])
}
}
} else {
print("Error: \(error!) \(error!.userInfo)")
}
}