iOS应用程序在segue崩溃(断点发生在func prepareForSegue) [英] iOS App crashes at segue (breakpoint occurs at func prepareForSegue)

查看:153
本文介绍了iOS应用程序在segue崩溃(断点发生在func prepareForSegue)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:我发现,通过阅读代码来调试非常困难,特别是在这样的情况下,


Update: I figuire out, it's very hard to debug just by reading through the code, especially in a situation like this,https://www.dropbox.com/s/ty3clsvgednzevj/LoaferMap%20for%20iPhone%20copy%202.zip?dl=0, so I upload my project to dropbox if you want to reproduce the bug. I deleted destination.delete(self), now it's gone. But the app still crashes. I realized the problem in SliderViewController maybe the code I wrote is simply unexcuteable. I'm a beginner, new to swift programming language. Your help means a lot to me.

If you download my project, and look at it. My goal is actually pretty straightforward, you use a slider to select a travel radius, and there are long lines of code generates a random location based on my current location. And finally pass that code to destinationViewController, to display a flyover animation based on the new generated location. But right now I think everything is set up correctly, but the app still crushes.

My app crashes when I'm about to transition form one view to the next.

     override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
         if (segue.identifier == "sendLocationdata") {
             let destination = segue.destinationViewController as! DestinationViewController

Thread 1, Breakpoint 1.1

   destination.latitude = latitude
   destination.longitude = longitude
          }

More source code in the VC, and next VC, you can check another question I asked How to Pass Data from View Controllers?.

解决方案

segue.destinationViewController

is not destinationViewController this class is a UINavigationController

you have to set latitude and longitude to UINavigationController's rootViewController

please edit like this

这篇关于iOS应用程序在segue崩溃(断点发生在func prepareForSegue)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆