ios - 在 Parse 中查询 currentUser 数据以使用 Swift 填充 TableView ViewController 时遇到问题

标签 ios swift parse-platform

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

相关文章:

iphone - iPhone 中的 UISegmentedControl 导航问题

ios - 警告 : Signed shift result (0x1F0000000) requires 34 bits to represent, 但 'int' 只有 32 位

ios - swift 2 : Can't find audio file path when I use variables as file names

typescript - 如何使用 Typescript 而不是 Javascript 在解析服务器中编写云代码?

javascript - 上传图片 parse.com

ios - 单击 Swift 4 中的自定义按钮时调整单元格大小

ios - 通用对象作为 HandyJSON 的参数

ios - ARKit/SpriteKit - 将 pixelBufferAttributes 设置为 SKVideoNode 或以另一种方式在视频中制作透明像素(色度键效果)

ios - xamarin iOS : Location Request how to find out when user clicks “Allow” or “Don' t allow” is clicked

ios - 如何在解析中从对象中获取 ObjectId 并在 swift 中将其显示为字符串