小编Enr*_*nti的帖子

快速致命的错误:'试试!' 表达式意外地引发了一个错误:错误Domain = NSCocoaErrorDomain Code = 3840"垃圾结束时".

我的swift程序一直出现这个错误,我使用PHP和MySQL作为数据库.我将数据从数据库显示到tableview.它以前工作但经过几次运行到模拟器后,我一直有同样的错误

class Home: UIViewController, UITableViewDelegate, UITableViewDataSource {

@IBOutlet weak var btnaddclass: UIButton!
@IBOutlet var tableView: UITableView!
   var values: NSArray = []

func get(){
    let url = NSURL(string: "http://localhost/show_db.php")
    let data = NSData(contentsOf: url! as URL)
    values = try! JSONSerialization.jsonObject(with: data! as Data, options:JSONSerialization.ReadingOptions.mutableContainers)as! NSArray
    tableView.reloadData()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return values.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! SpecialCell
    let maindata …
Run Code Online (Sandbox Code Playgroud)

ios swift swift3.0.2

2
推荐指数
2
解决办法
8934
查看次数

标签 统计

ios ×1

swift ×1

swift3.0.2 ×1