Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios ';UITableViewCell';没有名为'的成员;businessLabel';_Ios_Swift_Uitableview - Fatal编程技术网

Ios ';UITableViewCell';没有名为'的成员;businessLabel';

Ios ';UITableViewCell';没有名为'的成员;businessLabel';,ios,swift,uitableview,Ios,Swift,Uitableview,我在尝试配置一个原型单元以用于几个阵列时遇到了一个奇怪的错误。我已经设置了一个由“BDTableViewController”管理的表视图控制器,它包含一个由类“BDTableViewCell”管理的原型单元。然而,Xcode抱怨说 “UITableViewCell”没有名为“businessLabel”的成员 当businessLabel outlet明确链接到我的BDTableViewCell时。包括文件本身。你知道哪里出了问题吗 BDTableViewController: import

我在尝试配置一个原型单元以用于几个阵列时遇到了一个奇怪的错误。我已经设置了一个由“BDTableViewController”管理的表视图控制器,它包含一个由类“BDTableViewCell”管理的原型单元。然而,Xcode抱怨说

“UITableViewCell”没有名为“businessLabel”的成员

当businessLabel outlet明确链接到我的BDTableViewCell时。包括文件本身。你知道哪里出了问题吗

BDTableViewController:

import UIKit

class BDTableViewController: UITableViewController, UITableViewDelegate {


var BusinessNameArray = [String]()
var BusinessLogoArray = [String]()
var BusinessAddressArray = [String]()
var BusinessNumberArray = [String]()
var BusinessWebsiteArray = [String]()

override func viewDidLoad() {
    super.viewDidLoad()

    BusinessNameArray = ["Premiere Dance"]
    BusinessLogoArray = ["PD.tiff"]
    BusinessAddressArray = ["30 Brower Lane, Hillsborough, NJ 08844"]
    BusinessNumberArray = ["(908) 281-9442"]
    BusinessWebsiteArray = ["http://premieredancenj.com/"]


    // Do any additional setup after loading the view.
}

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 BusinessNameArray.count
}


override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    var cell = tableView.dequeueReusableCellWithIdentifier("Cell") as! UITableViewCell

    let item = BusinessNameArray[indexPath.row]

    cell.businessLabel.text = item




    return cell
}
}
BDTableViewCell:

import UIKit

[![enter image description here][1]][1]class BDTableViewCell: UITableViewCell {

@IBOutlet weak var businessLogo: UIImageView!
@IBOutlet weak var businessLabel: UILabel!
@IBOutlet weak var businessAddress: UILabel!
@IBOutlet weak var businessPhone: UILabel!
@IBOutlet weak var businessWebsite: UILabel!

override func awakeFromNib() {
    super.awakeFromNib()
    // Initialization code
}

override func setSelected(selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: animated)

    // Configure the view for the selected state
}

}
用这条线

var cell = tableView.dequeueReusableCellWithIdentifier("Cell") as! UITableViewCell
您让编译器知道,
cell
只是一个
UITableViewCell
,但是常规的
UITableViewCell
没有名为
businessLabel
的属性。当你把线路换成

var cell = tableView.dequeueReusableCellWithIdentifier("Cell") as! BDTableViewCell

代码将编译。

并确保原型单元的属性检查器中指定了
BDTableViewCell
。@AdrianB如果不是这样,他将无法连接故事板中的插座。