I'm extracting data from Mssql.
(我正在从Mssql提取数据。)
I want to print the data I received from the database to tableview, but I get the error "Could not cast value of type '__NSCFString' (0x7fff87a89460) to 'NSArray' (0x7fff87a8a310)". (我想将我从数据库收到的数据打印到tableview,但是出现错误“无法将类型'__NSCFString'(0x7fff87a89460)的值强制转换为'NSArray'(0x7fff87a8a310)”。)
I assign the data to the value variable. (我将数据分配给value变量。)
How can I solve the problem? (我该如何解决这个问题?)
class MakaleController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet var makaleTable: UITableView!
var stringvalue: [String] = []
override func viewDidLoad() {
super.viewDidLoad()
let client = SQLClient.sharedInstance()!
client.connect("...") { success in
client.execute("SELECT Email FROM ...", completion: { (_ results: ([Any]?)) in
for table in results as! [[[String:AnyObject]]] {
for row in table {
for (columnName, value) in row {
self.stringvalue = value as! [String]
}
}
}
client.disconnect()
})
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
(func tableView(_ tableView:UITableView,cellForRowAt indexPath:IndexPath)-> UITableViewCell {)
let cell:UITableViewCell = self.makaleTable.dequeueReusableCell(withIdentifier: "makalecell") as! UITableViewCell
cell.textLabel?.text = self.stringvalue[indexPath.row]
return cell
}
}
ask by SH Yaz?l?m Geli?tirme translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…