简体   繁体   English

iOS:选择选项第一次返回空值,而不是第二次返回

[英]iOS: selecting option returns null first time, not second time

I have an iOS application where you select an option before you log in. The way it works is that you click on the button that says "Select", then it takes you to a UITableViewController which shows you the options, you select the option, and it takes you back to the previous menu with the text replaced with your selection (and a hidden ID saved, too). 我有一个iOS应用程序,您可以在登录前选择一个选项。它的工作方式是,单击显示“选择”的按钮,然后带您到一个UITableViewController,该菜单向您显示选项,选择该选项,然后将您带回到上一个菜单,其中的文本已替换为您的选择(并且还保存了一个隐藏的ID)。

During the update of the information (which takes place in tableView:didSelectRowAtIndexPath:) I call NSLog on the object. 在信息更新过程中(发生在tableView:didSelectRowAtIndexPath:中),我在对象上调用了NSLog。 The first time I call it, it returns null (BUT for some reason the text still changes!) and the second time I call it, it works! 第一次调用它,它返回null(但是由于某种原因,文本仍然会改变!),第二次调用它,它可以工作! Why doesn't it work the first time???? 为什么第一次不起作用????

Thanks 谢谢

您是否将NSLog行放在上一个视图推回代码之前?

The variable was named incorrectly. 变量命名不正确。 I don't know why XCode didn't just tell me this instead of giving me an EXC_BAD_ACCESS, but that's what happened. 我不知道为什么XCode不只是告诉我这个而不是给我EXC_BAD_ACCESS,但这就是发生的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM