使用未声明的类型问题

Use of undeclared type issue

在我关于此代码选择示例的最后一个函数中,Xcode 正在生成“使用未声明的类型 'allEntries' 错误。我已经查看了有关此主题的几篇文章,但仍有问题。不确定使变量 public 是这里的问题,因为它们都在同一个 class.

import UIKit

class AllEntriesTableViewController: UITableViewController {

var passedValue = ""
var allEntries = [String]()

override func viewDidLoad() {
    super.viewDidLoad()


    var user = PFUser.currentUser()
    let event = PFObject(className:"event")
    var query = PFQuery(className:"event")
    query.whereKey("user", equalTo: user)
    query.includeKey("category")
    let category = event["category"] as NSString
    query.findObjectsInBackgroundWithBlock {
    (objects: [AnyObject]!, error: NSError!) -> Void in
    if error == nil {
    // The find succeeded.
    self.allEntries.removeAll(keepCapacity: true)
    // Do something with the found objects
    for object in objects {
        var allEnt:String = object as String
        self.allEntries.append(allEnt)
        //self.allEntries.append(allEnt.category)
    }
    } else {
    // Log details of the failure
    NSLog("Error: %@ %@", error, error.userInfo!)
    }
    }



    // Uncomment the following line to preserve selection between presentations
    // self.clearsSelectionOnViewWillAppear = false

     //Uncomment the following line to display an Edit button in the navigation bar for this view controller.
     //self.navigationItem.rightBarButtonItem = self.editButtonItem()
        }

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

// MARK: - Table view data source

override func numberOfSectionsInTableView(tableView: UITableView!) -> Int {
    // #warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1
}

override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
    // #warning Incomplete method implementation.
    // Return the number of rows in the section.
    return 3
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cellsForSection: [allEntries] = sections[indexPath!.section] as Array
    return cellsForSection[indexPath!.row] as allEntries

allEntries 是一个变量而不是 class。因此,像你最后一行那样的演员表

as allEntries

不起作用。您必须 return cellForRowAtIndexPathUITableViewCell 类型的对象。