ios - crash linked to swift_dynamicCast in prepareForSegue -
first of all, here's code:
let flickerfetcher : flickrfetcher = flickrfetcher() var photos : uiimage[]? = uiimage[]() { didset { self.appstableview.reloaddata() } } func prepareimageviewcontroller(ivc: imageviewcontroller, todisplayphoto photo: nsdictionary) { ivc.imageurl = flickerfetcher.urlforphoto(photo, format: flickrfetcher.flickrphotoformat.large) ivc.title = photo.valueforkeypath(flickerfetcher.flickr_photo_title) string } // in storyboard-based application, want little preparation before navigation override func prepareforsegue(segue: uistoryboardsegue!, sender: anyobject!) { // new view controller using [segue destinationviewcontroller]. // pass selected object new view controller. // nslog("prepare segue beginning") if sender!.iskindofclass(uitableviewcell) { // nslog("sender uitableviewcell") var indexpath : nsindexpath = self.tableview.indexpathforcell(sender uitableviewcell) if indexpath != nil { // nslog("indexpath nil") if segue!.identifier == "display photo"{ // nslog("segue identified") if segue!.destinationviewcontroller.iskindofclass(imageviewcontroller) { nslog("destinationviewcontroller imageviewcontroller") var destinationcontroller = segue.destinationviewcontroller imageviewcontroller if allow photodict = self.photos?[indexpath.row] as? nsdictionary { self.prepareimageviewcontroller(destinationcontroller, todisplayphoto:photodict) } } } } } } i've narrowed problem downwards implementation of prepareimageviewcontroller on lastly line gives me crash linked swift_dynamiccast. can't seem figure out.
try , create sure photos dictionary before using it.
if allow photodict = self.photos?[indexpath.row] as? nsdictionary { self.prepareimageviewcontroller(destinationcontroller, todisplayphoto:photodict) } ios swift cs193p
No comments:
Post a Comment