我对 Parse 相当陌生..我正在尝试查询当前用户的数据并在“用户个人资料” View Controller 中填充 TableView 。我正在尝试在“产品”类中显示当前用户的列。
这是我所拥有的...
class UserProfileViewController: UIViewController, UITableViewDelegate {
@IBOutlet var userProductTableView: UITableView!
var userProductImagePNG = [PFFile]()
var userProductShortDescription = [String]()
var userProductTitle = [String]()
var userProductPrice = [String]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
var userQuery = PFQuery(className: "Product")
userQuery.whereKey("user", equalTo: PFUser.currentUser()!)
userQuery.orderByDescending("createdAt")
userQuery.findObjectsInBackgroundWithBlock {
(userProducts: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
// success fetching objects
for userProduct in userProducts! {
println(userProducts?.count)
}
}else {
println(error)
}
每次我尝试运行该应用程序时,它都会告诉我......
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7fa74b40fae0'
如果问题不是很清楚,我深表歉意。我是第一年程序员:/
最佳答案
UITableView 必须有一个充当数据源的对象和一个充当委托(delegate)的对象。因此,就您而言,您似乎想要
self.delegate = self;
self.dataSource = self;
这意味着,您所在的 currentv View (自身)负责实现适当的委托(delegate)和 dataSource 方法,当 UITableView 想要填充其内容时,将调用这些方法。
您可以为 UITableViewDataSource 和 UITableViewDelegate 实现适当的委托(delegate)方法来填充适当的信息
关于ios - 在 Parse 中查询 currentUser 数据以使用 Swift 填充 TableView ViewController 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30858748/