Swifty JSON UITableView 后台报错

Swifty JSON UITableView background error

我已经学习了 Ray Wenderlich 中的教程。但是我没有将数组直接放入 UITableView。现在将 JSON 加载到 UITableView 大约需要 20 秒。但是在控制台日志中,阵列是直接可用的。我在 Swift 2.0.

工作
@IBOutlet var tableView: UITableView!

let textCellIdentifier = "CoffeeLocations"
var apps : [String] = []

override func viewDidLoad() {
    super.viewDidLoad()

    tableView.delegate = self
    tableView.dataSource = self

    // Do any additional setup after loading the view.
    DataManager.getTopAppsDataFromItunesWithSuccess { (iTunesData) -> Void in
        let json = JSON(data: iTunesData)

        if let appArray = json[].array {

            for appDict in appArray {
                let appName: String? = appDict["name"].string
                self.apps += ["\(appName!)"]
            }

            print(self.apps) // Here he print directly to the console log
            self.tableView.reloadData()
        }
    }
}

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return apps.count
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier(textCellIdentifier, forIndexPath: indexPath) as! TableViewCell
    let row = indexPath.row
    cell.titleLabel!.text = apps[row]
    //cell.detailLabel!.text = description[row] Later I want to add a second rule
    return cell
}


override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

错误日志(直接):

2015-09-24 09:45:31.493 TopApps[660:180190] Received memory warning. ["\'t Koffiehuisje", "Caffee Allee | Stadsrestaurant", "Ketelhuis", "Monk Eindhoven", "Radio Royaal", "PopEi Food & Drinks", "Tijdelijk restaurant", "NATLAB", "Bagel & Juice", "Pastry club", "Intellegentia ICE", "Onder de leidingstraat", "Keukenconfessies"]

数组中每一行的错误日志(20 秒后):

2015-09-24 09:46:09.579 TopApps[660:180231] This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release. Stack:( 0 CoreFoundation 0x0000000182bb0f74 + 148 1 libobjc.A.dylib 0x00000001977a3f80 objc_exception_throw + 56 2 CoreFoundation 0x0000000182bb0ea4 + 0 3 Foundation 0x0000000183bca5d8 + 88 4 Foundation 0x0000000183a4ca1c + 36 5 UIKit 0x000000018820b958 + 64 6 UIKit 0x00000001881022d8 + 240 7 UIKit 0x0000000188101b8c + 116 8 UIKit 0x0000000188101a18 + 504 9 UIKit 0x00000001884098e0 + 228 10 UIKit 0x0000000188100458 + 412 11 UIKit 0x00000001881fae14 + 1440 12 UIKit 0x00000001881efab8 + 216 13 UIKit 0x000000018810300c + 644 14 QuartzCore 0x0000000187909f14 + 148 15 QuartzCore 0x0000000187904b20 + 292 16 QuartzCore 0x00000001879049e0 + 32 17 QuartzCore 0x000000018790407c + 252 18 QuartzCore 0x0000000187903dd0 + 516 19 QuartzCore 0x0000000187932f48 + 236 20 libsystem_pthread.dylib 0x00000001981b21e8 + 584 21 libsystem_pthread.dylib 0x00000001981b1d60 + 136 22 libsystem_pthread.dylib 0x00000001981b1544 pthread_mutex_lock + 0 23 libsystem_pthread.dylib 0x00000001981b1028 start_wqthread + 4 )

dispatch_async(dispatch_get_main_queue(), {
    // put your code here  load the JSON into the UITableView
})