0
我有搜索关于歧义引用成员'下标'但找不到任何解决方案。我正在使用TableView。这是我正在使用的代码: -对Xcode 8中成员'下标'的歧义引用
let people = [
["Pankaj Negi" , "Rishikesh"],
["Neeraj Amoli" , "Dehradun"],
["Ajay" , "Delhi"]
];
// return the number of section
func numberOfSections(in tableView: UITableView) -> Int {
return 1;
}
// return how many row
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return people.count;
}
// what are the content of the cell
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell();
var (personName , personLocation) = people[indexPath.row] // Ambiguous Reference to member 'subscript'
cell.textLabel?.text = personName;
return cell;
}
我是IOS开发新手,为什么我很难理解这一点。但是这个代码在Xcode 6中工作,但不在Xcode 8中。为什么我不知道?
谢谢,@Nirav D,我做了2D数组,但我需要一个元组的数组,在这种情况下,这就是它显示这个错误的原因。用'['代替'(')是我这边愚蠢的错误。 –