我对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'


如果问题不是很清楚,我对此表示歉意。我是第一年的程序员:/

最佳答案

UITableView必须具有充当数据源的对象和充当委托的对象。所以在您的情况下,您似乎想要

self.delegate = self;
self.dataSource = self;


这意味着,您所在的currentv视图(自身)负责实现适当的委托和dataSource方法,当UITableView看起来填充其内容时将调用这些方法。

比您可以为UITableViewDataSource和UITableViewDelegate实现适当的委托方法以填写适当的信息

关于ios - 在解析中查询currentUser数据时遇到麻烦,无法使用Swift填充Table View ViewController,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30858748/

10-10 21:11
查看更多