Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode LLDB Print Statements Fail - NSUndoManager

I have a breakpoint set and want to print my UITextField's superview. I type po myTextField.superview but I receive the following error:

error: instance method 'undoManager' has incompatible result types in different translation units ('id' vs. 'NSUndoManager *')
note: instance method 'undoManager' also declared here
error: 1 errors parsing expression

What does this mean and how can I print my superview? I found a link that provides a janky workaround in code: http://openradar.io/15890965, but I would like a better solution.

like image 894
rizzes Avatar asked Jun 09 '14 17:06

rizzes


3 Answers

People of the world: I have an answer!

To dodge all UIKit errors: Before typing your po statement, type the line -- expr @import UIKit

If you want to turn this on for your app globally, then add the following breakpoint in your app delegate:

enter image description here

Thanks to Craig Hockenberry and Steve Streza for the update (found here).

like image 195
rizzes Avatar answered Nov 11 '22 09:11

rizzes


The solution I use to prevent this error while debugging is to explicitly cast everything.

In your case I would do

po [(UITextField *)myTextField superView]
like image 1
bhargavg Avatar answered Nov 11 '22 10:11

bhargavg


Do you have any custom accessor methods for 'myTextField'? I have seen this same issue a number of times and it is usually caused by the po trying to print a property for an object that gets initialized the first time its getter is called. For example, if I try to run 'po self.imageView.contentMode' on a UITableViewCell I get that same error. Try moving your breakpoint to a point in the code where you know that 'myTextField' has been fully initialized.

like image 1
pbuchheit Avatar answered Nov 11 '22 10:11

pbuchheit