What is causing NSNull length unrecognized selector keyCommand error

会有一股神秘感。 提交于 2019-11-27 15:09:10

Ok I deleted the navigation controllers and tab bar controller and re-added them, and the problem is gone! There are no more crashes when I type in data. It was obviously a corrupted scene but the weird thing is that all of a sudden, all scenes with uitextfields got corrupted in the same way.

I'd like to add that advanced SO users should really take the time to talk to users posting issues before they down vote. Or users should then be allowed to up-vote the question back because it's really unfair that some people jump to conclusions and start down voting to a question that is actually a valid issue.

I had a crash with the same cryptic NSNull length message. It cropped up occasionally on only one screen when testing in the simulator and by trial and error I discovered it only happened when I pressed the cmd key.

Looking in my storyboard source I found the following:

                <keyCommands>
                    <keyCommand/>
                </keyCommands>

Which I think lets you define keyboard shortcuts for anyone using a bluetooth keyboard. However - this is an empty definition, so it seems pressing cmd caused whatever this executes to fail because I don't have any valid shortcuts defined.

I have absolutely no idea how this happened, but if you use the graphical Interface Builder UI to look at your Storyboard, go to the view controller giving you the problem and click on the root view controller. Under the Attributes inspector there is a Key Commands section. I reckon I must have accidentally hit the + button here at some point. You can select the first 'item' and hit - to get rid of it and the problem should disappear.

Alternatively, delete the keyCommands section from the Storyboard source directly.

I see this question has already been marked as answered, but I include this in case the additional information on top of the original answer (and comment) is useful to someone else.

Click on view controller and in attributes inspector under Key commands remove "Enter action below" entry

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