我正在尝试将数据从一个视图控制器推送到另一个视图控制器。我已将一个视图控制器连接到另一个视图控制器的导航控制器,然后将标识符设置为“showItemSegue”。这两行代码出现错误:
var detailController = segue.destinationViewController as ShowItemViewController
detailController.currentId = nextId!
图像说明:
代码:
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
nextId = itemArray?.objectAtIndex(indexPath.row).objectForKey("objectId") as? NSString
self.performSegueWithIdentifier("showItemSegue", sender: self)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if (segue.identifier == "showItemSegue") {
var detailController = segue.destinationViewController as ShowItemViewController
detailController.currentId = nextId!
}
}