В моей последней функции в этом примере выбора кода Xcode генерирует ошибку «Использовать необъявленный тип» allEntries. Я просмотрел несколько сообщений по этой теме и все еще имею проблемы. Не уверен, что сделать переменную общественность вопрос здесь, так как все в том же классе.Использование проблемы с необъявленным типом
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' - это * переменная *, а не * тип *, поэтому' let cellForSection: [allEntries] = ... 'и' ... as allEntries' не имеет никакого смысла. Что вы ожидали от этого? –
пытаясь вернуть массив allEntries в качестве ячеек, я собираюсь сделать все это неправильно? – DelphiData