Pass data Through segue not working in swift 3 any solution?

拜拜、爱过 提交于 2019-12-02 16:55:03

问题


i have passed data from didselect method of collectionView like this

 func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {

        let dicttemp = (arrRespProduct?.object(at: indexPath.row))! as! NSDictionary
        dicData = NSMutableDictionary(dictionary: dicttemp)

         performSegue(withIdentifier: GlobalConstant.segueIdentofier.productDetail, sender: self)
    }

But method

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

is not calling in swift 3... Any solution?


回答1:


prepareForSegue is changed in swift 3.0 so you need to write like this

override func prepare(for segue: UIStoryboardSegue, sender: Any?){

}



回答2:


In addition to above answer you should expect a lot of changes of method names like: prepareForSegue to prepare or String.substringFromIndex to String.substring. The obvious method name endings are ommited/moved to the label of 1'st argument.



来源:https://stackoverflow.com/questions/39533609/pass-data-through-segue-not-working-in-swift-3-any-solution

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!