gpt4 book ai didi

ios - 崩溃链接到 prepareForSegue 中的 swift_dynamicCast

转载 作者:行者123 更新时间:2023-11-28 05:34:46 29 4
gpt4 key购买 nike

首先,这是我的代码:

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) as String
}

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
// NSLog("Prepare for Segue beginning")
if sender!.isKindOfClass(UITableViewCell) {
// NSLog("Sender is UITableViewCell")
var indexPath : NSIndexPath = self.tableView.indexPathForCell(sender as UITableViewCell)
if indexPath != nil {
// NSLog("IndexPath is nil")
if segue!.identifier == "Display Photo"{
// NSLog("Segue Identified")
if segue!.destinationViewController.isKindOfClass(ImageViewController) {
NSLog("DestinationViewController is ImageViewController")
var destinationController = segue.destinationViewController as ImageViewController
if let photoDict = self.photos?[indexPath.row] as? NSDictionary {
self.prepareImageViewController(destinationController, toDisplayPhoto:photoDict)
}

}
}
}
}

}

我已将问题缩小到最后一行的 prepareImageViewController 的实现,它给我一个链接到 swift_dynamicCast 的崩溃。我似乎无法弄清楚。

最佳答案

在使用之前,请尝试确保您的照片字典是正确的。

if let photoDict = self.photos?[indexPath.row] as? NSDictionary {
self.prepareImageViewController(destinationController, toDisplayPhoto:photoDict)
}

关于ios - 崩溃链接到 prepareForSegue 中的 swift_dynamicCast,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24426935/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com