价值铸造问题:无法转换类型' __ NSCFDictionary' to' cards_basic.Card'

时间:2015-08-02 11:52:18

标签: ios swift

UPDATE2

我希望的行为是将卡片从tableview传递到详细视图。当JSON / Alamofire没有参与时我已经做了好几次,但现在当包含卡片的数组显示在tableview上然后我尝试通过tapped卡执行segue到详细视图时,我得到错误描述在这里

更新

var cards = [Card]()
var cardToPass: Card!

我从api端点检索JSON数组,在TableView中显示,然后尝试导航到详细视图,如下所示:

func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
    var locValue:CLLocationCoordinate2D = manager.location.coordinate

    let data = [...] // real data here in the code

    self.locationManager.stopUpdatingLocation()

    Alamofire.request(.GET, API["PROTOCOL"]! + API["HOST"]! + API["URL"]!, parameters: data)
        .responseJSON { _, _, JSON, _ in
            self.cards = JSON as! [AnyObject]
            self.tableView.reloadData()
            self.refreshControl?.endRefreshing()
    }
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
    if (segue.identifier == "toSharedDetailCard") {
        let viewController = segue.destinationViewController as! SharedDetailController
        viewController.passedCard = cardToPass
    }
}

我收到此行Could not cast value of type '__NSCFDictionary' (0x105672a60) to 'cards_basic.Card' (0x104ccf970).的错误viewController.passedCard = cardToPass,我真的不知道如何修复它。

0 个答案:

没有答案