iOS App crashes at segue (breakpoint occurs at func prepareForSegue)

我怕爱的太早我们不能终老 提交于 2019-12-02 02:23:49

问题


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?.


回答1:


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



来源:https://stackoverflow.com/questions/37982076/ios-app-crashes-at-segue-breakpoint-occurs-at-func-prepareforsegue

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