私のデータはオブジェクトメニューを作成することで、メニューという名前のモーダルクラスに入っています。今、どのように私はすべてのデータがテーブルビューにデータを表示するためのコードを追加したobject.Iメニューの助けによって、Menuクラスに保存されている特定のセルクラスモデルからテーブルビューにデータを取り込む方法
var menus = [Menu]()
for (_, content) in json {
let menu = Menu(id: Int(content["id"].stringValue),
name: content["name"].string,
image: content["image"].string,
coupon: content["coupon"].int,
icon: content["icon"].string,
order: Int(content["order"].stringValue),
aname: content["name"].string,
options: Int(content["options"].stringValue),
subcategory:content["subcategory"].arrayObject)
menus.append(menu)
}
for menu in menus {
print(menu.name)
print(menu.id)
print(menu.subcategory)
}
print(menus.count)
ここに表示するテーブルビューにメニュー名を送信することができます。ここで私はカスタムテーブルビューを作成し、それを設定しようとしています
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return menus.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Menucell", forIndexPath: indexPath)as! MENUTableViewCell
cell.Ordermenu.text = (" \(menus[indexPath.row])")///here its not fetching the value
return cell
}
それは機能しません。実装はどのようにすべきか?
それはprojectName.classname
ええ、このオプションの値(値)は任意です。 –
私の答えごとにコードを変更した後の画面のスクリーンショットを付けることはできますか? –
ええ、あなたのコードは機能していますが、マイナーエラーだけです –