Получился вот такой неработающий код ((
Помогите пожалуйста воткнуть данные в тейбл вю
//
// FirstViewController.swift
// The Loft
//
// Created by dlilb inc. on 11.11.2017.
// Copyright © 2017 dlilb inc. All rights reserved.
//
import UIKit
struct myRows: Decodable {
var rows: [massiv]
}
struct massiv: Decodable {
var id: String
var pagetitle: String
var parent: String
}
class FirstViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return (animals.count)
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! FirstTableViewCell
cell.myLabel.text = myRows[indexPath.row].pagetitle
return (cell)
}
override func viewDidLoad() {
super.viewDidLoad()
let urlString = "http://theloft.su/ios/json_meropriyatiya.json"
guard let url = URL(string: urlString) else {return}
URLSession.shared.dataTask(with: url) { (data, response, error) in
guard let data = data else {return}
guard error == nil else {return}
do {
let myJSON = try JSONDecoder().decode(myRows.self, from: data)
print(myJSON)
} catch let error {
print(error)
}
}.resume()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
}