小编Tee*_*eeJ的帖子

如何从JSON中填充Swift 2中的tableView?

一个新的程序员在这里.我如何从这个JSON填充我的tableView?
我的第一个问题是JSON序列化,然后将其插入tableView.

import UIKit

class LegislatorsTableVC: UITableViewController {

// MARK: Variables & Outlets
private let cellIdentifer = "cellReuse"

// MARK: View Did Load
override func viewDidLoad() {
    super.viewDidLoad()

    // Creating Congfiguration Object // Session Is Created // Getting Info/Data
    let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
    let session = NSURLSession(configuration: configuration)
    let apiKey = "https://congress.api.sunlightfoundation.com/legislators?apikey=xxxxxxxxxxxxxxxxxxxxx&all_legislators=true&per_page=all"

    if let url = NSURL(string: apiKey) {
        // Spawning Task To Retrieve JSON Data
        session.dataTaskWithURL(url, completionHandler: { (data, response, error) -> Void in
            // Checking For Error …
Run Code Online (Sandbox Code Playgroud)

json uitableview ios swift2

1
推荐指数
1
解决办法
4022
查看次数

标签 统计

ios ×1

json ×1

swift2 ×1

uitableview ×1