swift trace “unexpectedly found nil” to the source

前端 未结 2 329
野的像风
野的像风 2021-01-07 08:10

Is there a way to find out which object is Nil? I get these errors from time to time while coding and normally I have no trouble finding them because I test my code frequent

相关标签:
2条回答
  • 2021-01-07 08:45

    That's what the Debug navigator is for. It shows the entire stack trace. And it is interactive: click a line of the call stack and you are taken to the line of code, at that level of the stack trace, where the problem is.

    enter image description here

    0 讨论(0)
  • 2021-01-07 09:01

    When you run into this error you should be able to browse through current assigned values in the box in the picture below. look at the box on the bottom left, you can look at any currently assigned value at the time of error. in this case the error is from attempting to read from a file that does not exist

    Here is a better example enter image description here

    0 讨论(0)
提交回复
热议问题