Ios 在prepareForSegue与swift_dynamicCast发生碰撞
首先,这是我的代码:Ios 在prepareForSegue与swift_dynamicCast发生碰撞,ios,swift,cs193p,Ios,Swift,Cs193p,首先,这是我的代码: let flickerFetcher : FlickrFetcher = FlickrFetcher() var photos : UIImage[]? = UIImage[]() { didSet { self.appsTableView.reloadData() } } func prepareImageViewController(ivc: ImageViewController, toDisplayPhoto photo: NSDictionary) {
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)
}
伴随崩溃的错误是什么?如果没有,您是否尝试过跟踪?它是
线程1:EXC\u断点(code=EXC\u I386\u BPT,subcode=0x0)
谢谢Connor,我本来就有这个,但在我试图找出错误的时候把它取出来了。还是有错误,是的,非常一样。这个看起来对吗func-URLforPhoto(photo:NSDictionary,format:FlickrPhotoFormat)->NSURL{return-NSURL(coder:self.urlStringForPhoto(photo,format:format)as-NSCoder)}
我试过了,不再出现错误,但似乎照片仍然没有打开。当segue发生时,它应该打开照片,照片的名称应该是新视图控制器的标题。标题现在正在显示,但照片没有显示