我对Parse 相当新。我正在尝试查询当前用户的数据并在“用户个人资料”中填充表格视图。查看控制器。我试图在"产品"中显示当前用户的列。类。
这是我的......
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)
}
每当我尝试运行应用程序时,这就是它告诉我的......
如果问题不是很明确,我会道歉。我是第一年的程序员:/由于未捕获的异常而终止应用 ' NSInvalidArgumentException',原因:' - [UIView tableView:numberOfRowsInSection:]:发送到的无法识别的选择器 实例0x7fa74b40fae0'
答案 0 :(得分:0)
UITableView必须具有充当数据源的对象和充当委托的对象。所以在你的情况下,看起来你想要
self.delegate = self;
self.dataSource = self;
这意味着,您所处的currentv视图(self)负责实现在UITableView查看其内容时将调用的相应委托和dataSource方法。
您可以为UITableViewDataSource和UITableViewDelegate实现适当的委托方法以填写相应的信息