JSONファイルを読み込むときの処理について
このQiitaの記事に従って勉強しようと思うのですが、
この記事だと、記事のコードをどのファイルに記述したらいいのか、いまいちよくわからないので、詳しく教えていただきたいです。
https://qiita.com/hiroyuki7/items/7e3e3bac6cd6ca187bf2
##設計
UITableView(TableViewController)を使ったView
→JSONファイルのデータをセルに一つずつ入れたい
TableViewController
import UIKit class TableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { override func viewDidLoad() { super.viewDidLoad() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } /// セルの個数を指定するデリゲートメソッド(必須) func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 10 } /// セルに値を設定するデータソースメソッド(必須) func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { // セルを取得する let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier("MyCell", forIndexPath: indexPath) return cell } }
mySample.json
{ "park":"higashiyama", "animals":["cat", "dog", "monkey", "rabbit"], "nickname":{"cat":"tama", "monkey":"jiro"} }
ご回答、よろしくお願いいたします。
回答2件
あなたの回答
tips
プレビュー