ios 覆盖prepareForSegue 函数时IBAction 中的线程错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25750595/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Thread error in IBAction while overriding prepareForSegue function
提问by Giacky
I'm getting a thread error Thread 1: Breakpoint 1.1
in my IBAction
function. The code runs without error, but when I click the button on the simulator, the simulator crashes and produces the breakpoint error. The affected code is:
Thread 1: Breakpoint 1.1
我的IBAction
函数出现线程错误。代码运行没有错误,但是当我单击模拟器上的按钮时,模拟器崩溃并产生断点错误。受影响的代码是:
@IBAction override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if testoEsercizio.text == "Per iniziare premi la tv" {
var viewController : SecondoSchermo = segue.destinationViewController as SecondoSchermo
viewController.stringaponte = "SI buono"
} else {
var viewController : SecondoSchermo = segue.destinationViewController as SecondoSchermo
viewController.stringaponte = "NON buono"
}
}
回答by Stephen Furlani
Open the breakpoint editor in Xcode with ? + 7
. From there you can see the breakpoints that are on (as indicated by dark blue) or off (with light blue). I highly suspect that you have a breakpoint set in your method.
在 Xcode 中打开断点编辑器? + 7
。从那里您可以看到打开(用深蓝色表示)或关闭(用浅蓝色表示)的断点。我非常怀疑您的方法中设置了断点。
The term Thread 1: Breakpoint 1.1
is the debugger's internal name for the breakpoint (I Assume you're reading this from the green bar of text?). It doesn't necessarily mean it is a
threading error, it's just telling you where it stopped.
该术语Thread 1: Breakpoint 1.1
是断点的调试器内部名称(我假设您是从绿色文本条阅读此内容的?)。这并不一定意味着这是一个线程错误,它只是告诉您它在哪里停止。
You can press ^ + ? + Y
to Continue, or go to the Debug Menu and select other options. ? + ? + Y
will bring up the Debug area and a bar of buttons which correlate to the Debug Menu's actions.
您可以按^ + ? + Y
继续,或转到调试菜单并选择其他选项。? + ? + Y
将显示调试区域和与调试菜单操作相关的按钮栏。
HTH
HTH
回答by Yves
it means indeed that you set a breakpoint in your code. If you did so by mistake, press CMD+7 to select all breakpoints in Xcode. In the breakpoint navigator on the left you can now select and delete your breakpoints with backspace
这确实意味着您在代码中设置了断点。如果您这样做是错误的,请按 CMD+7 选择 Xcode 中的所有断点。在左侧的断点导航器中,您现在可以使用退格键选择和删除断点
回答by cheznead
Have you accidentally added a breakpoint to your code? If so, program will run up until that point and then stop.
您是否不小心在代码中添加了断点?如果是这样,程序将运行到该点然后停止。
Check whether there are any blue arrows linked to some part of your program which mark a breakpoint.
检查是否有任何蓝色箭头链接到程序的某些部分,这些箭头标记了断点。
回答by Epitychia.lc
You can click on the (dark blue) sign, and the green message will go away. And the next part of your code will be accessible from simulation or else.
您可以单击(深蓝色)标志,绿色消息将消失。您的代码的下一部分将可以通过模拟或其他方式访问。
回答by Ahmad Binmana
To solve this issue you should follow this instructions.
要解决此问题,您应该按照此说明进行操作。
1- Go to Product in the toolbar.
1- 转到工具栏中的产品。
2- Then go to Scheme.
2-然后去计划。
3- And go to Edit scheme.
3-然后转到编辑方案。
4- Then click on Run(Debug).
4-然后单击运行(调试)。
5- in Run(Debug) there is Arguments Passed On launch just click on + then put this value on it (-v)
5- 在 Run(Debug) 中,有 Arguments Passed On launch 只需点击 + 然后把这个值放在它上面 (-v)
6- Close.
6-关闭。
回答by Hakeem Versatile Deggs
If you are having this problem, the easiest way to solve this issue is to click on the debug option in the tool menu at the top of the screen and you will then you find the option "deactivate breakpoints".
如果您遇到此问题,解决此问题的最简单方法是单击屏幕顶部工具菜单中的调试选项,然后您将找到“停用断点”选项。
回答by Muhammad Asher
Here's the two steps to solve this:
这是解决此问题的两个步骤:
Remove break point, by going to DEBUG
and DEACTIVATE ALL BREAK POINT
通过转到DEBUG
和删除断点DEACTIVATE ALL BREAK POINT
Then, go to Main.Storyboard
, right click on the area highlighted in red:
然后,转到Main.Storyboard
,右键单击以红色突出显示的区域:
Check that the yellow sign is present or not. If present then remove this. Code will run successfully. App will not crash.
检查黄色标志是否存在。如果存在,则删除它。代码将成功运行。应用程序不会崩溃。