This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Mysterious crash in xcode for ui based app
I built and debugged my single file ui based app in Pythonista. It works as expected. Then I downloaded the xcode template and pasted my code into Script.py. I then ran it and eventually it built and loaded. I started walking through the various features and things worked for a while but one particular button press causes a crash. It failed with error: "unrecognized selector sent to class" The crash dump is below.
Before I start posting python and asking for detailed help with my code I wonder if someone can give my advice on how to start debugging an xcode based failure like this. The error message is basically incomprehensible to me. I am an experienced C++ programmer but still stumble in ObjectiveC but even so I am baffled by the complete lack of symbolic annotation of things like the call stack.
The failure seems to be in an action callback for a button I added to the the top bar left_button_list. The callback's job is to switch views which it does with a sequence of remove/add _subviews with an .end_editing() thrown in to get rid of a TextField keyboard. I was trying to follow a suggestion omz made in a forum thread somewhere about switching views. It all works fine in Pythonista. How do I debug an xcode specific failure? While waiting for advice I will do the normal print based debug and try to identify the specific line of python code that is failing. The visual evidence seems to narrow it down the the small number of lines in the action callback method and the implicit TableView load that happens so that shouldn't take long. After I get a night's rest. ;-)
-steve (aka zencuke)
2014-10-30 03:35:14.283 PythonistaProject[523:61887] +[UIResponder om_firstResponder]: unrecognized selector sent to class 0x33448ea0
2014-10-30 03:35:14.286 PythonistaProject[523:61887] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UIResponder om_firstResponder]: unrecognized selector sent to class 0x33448ea0'
*** First throw call stack:
(0x24d05c1f 0x324b0c8b 0x24d0af55 0x24d08f57 0x24c3adf8 0x37338b 0x28481197 0x28485bd1 0x24c2d2df 0x24c2d1db 0x282947b3 0x3648b9 0x38a6b9 0x28ecad 0x291181 0x28ea51 0x28bf47 0x228b0d 0x1fff6b 0x20b071 0x1fff6b 0x2909e5 0x377507 0x281f5c2b 0x283596fd 0x281f5c2b 0x281f5bd1 0x281e0863 0x281f563d 0x281f5317 0x281eebe1 0x281c53dd 0x28438c29 0x281c3e39 0x24ccc377 0x24ccb787 0x24cc9ded 0x24c18211 0x24c18023 0x2c0110a9 0x282241d1 0x59783 0x32a30aaf)
libc++abi.dylib: terminating with uncaught exception of type NSException
JonB last edited by
I don't use xcode, but it appears that you can set a breakpoint in the debugger for that exception. Presumably, if you are running this code in the debugger you will get symbolic info in the stack trace..
Thank you. That was very helpful. At least it got me to the next step. This is a little tricky debugging python from failures in ObjectiveC, especially when you don't have source, especially when it works fine running in pythonista.
It fails in this code:
PythonistaProject`-[SUITableView tableView:didEndDisplayingCell:forRowAtIndexPath:] at simpleuimodule.m:
This is not surprising because my custom TableView data_source handler is a little tricky. The contents of the TableView need to change on this button press.
*** Question: Is there a right way to tell the ui code that it needs to start over with the TableView? Other than calling the reload() method?
If it uses an old tableview_number_of_rows value it may be calling tableview_cell_for_row for a row that doesn't exist and I might be generating a garbage TableViewCell.
Oops. I just noticed the following in the debug window.
self SUITableView * nil
_name NSString * nil
_pyObject PyObject * NULL
I wonder what happened to the TableView? It was on the screen and it is now nil. remove_subview must delete it. I expected to just take it out of the list. On the other hand if that were true why would the code work in the Pythonista app. I wish it would fail in the app. I know how to debug that.
I guess I need to figure out enough Markdown to protect code from being reformatted. That message got pretty trashed.
dgelessus last edited by
Use single backticks/grave accents (`) to enclose single lines of code.
Use three backticks/grave accents (```) to start and end multi-line blocks of code. The start of a code block must have a blank line before it.
Add python directly after the opening backticks/grave accents to add Python syntax highlighting. This is not standard Markdown and only works on the forums and GitHub. The latter also supports this for various other languages.
Also use the preview window. It practically always displays the result you'll see when posting the message, except for Python code blocks, because they are not standard Markdown.
Bonus: to type literal backticks in your message, simply do not include closing ones. For single ones, this means using an odd number of backticks on one line, where the last one will always be the escaped one. For triple backticks, use an odd number of triple backtick groups in your message, where the last one will again be escaped.
Issue resolved. See "Debugging standalone" thread.