私はiOSを初めて使用し、いくつかのチュートリアルを開始しました。しかし、tableview
にコンテンツを表示しようとすると、表示されません。私はそのチュートリアルでやったようにすべてをやった。しかし、私は自分のテーブルビューで私のcontetntを表示することができませんでした。データがテーブルビューに表示されない
ここに私のtutoialリンク:My link
ここに私のコード:
import UIKit
import Alamofire
class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
var nameArray = [AnyObject]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
Alamofire.request("http://thecodeeasy.com/test/swiftjson.json").responseJSON { response in
let result = response.result
if let dict = result.value as? Dictionary<String,AnyObject>{
if let mainDict = dict["actors"] {
self.nameArray = mainDict as! [AnyObject]
self.tableView.reloadData()
}
}
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return nameArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath as IndexPath) as? CustomTableViewCell
let title = nameArray[indexPath.row]["title"]
cell?.ContentName.text = title as? String
return cell!
}
}
はそれがSWIFT 3.0であるありがとうコードへのリンクを確認してください? –
はい....... –
Alamofire.request( "http://thecodeeasy.com/test/swiftjson.json")を書きます。viewdidloadの代わりに –