ios - 使用 json 填充的单元格准备segue

标签 ios json swift uitableview

我用这种方式填充 UITableViewCell 的 json 数据

 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("jsonCell") as! Celda
    var dict = arrRes[indexPath.row]
    cell.nombre1.text = dict["nombre"] as? String
    cell.nombre2.text = dict["calle"] as? String
    cell.id.text = dict["id"] as? String
    return cell

但是我无法传递我的数据,如果我想传递id文本,我的prepareforsegue代码是什么?

最佳答案

您应该进行一些尝试,然后发布您的尝试。但这是一个例子......

  override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

    if segue.identifier == "Identifier"  {
        let navigationContoller = segue.destinationViewController as! UINavigationController
        let controller = navigationContoller.topViewController as! MyViewControllerToSegueTo
        let indexPath = self.tableView.indexPathForSelectedRow
        let dataToPass = data[indexPath!.row]
        controller.recieveingVariable = dataToPass
    }
}

关于ios - 使用 json 填充的单元格准备segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35095980/

相关文章:

ios - Swift 3/iTunesConnect 实时跟踪应用程序销售情况

c# - C# Newtonsoft 中的 JSON 数组迭代

java - JSON 异常错误

ios - 如何解决“+”符号在iOS上反转的问题?

ios - (UITabBarController *)self.window.rootViewController;

javascript - 如何通过 AirWatch 浏览器调试在 iOS 中运行的 Web 应用程序?

javascript - 使用 Angular 平移进行本地化

ios - Safari 无法打开页面 - 错误是, "The URL can' t 无法显示” - 与深层链接有关?

swift - ModelIO 框架不工作

ios - Swift - 在 AppDelegate 中实例化 View Controller