How to show objective-c description in xcode

I have a question about the "Show Summaries" feature in Xcode that the guys are talking about.

I am currently implementing description and debugDescription in my Objective-C classes, so that I can just type po myObject to get a quick look at the content, and that saves time.

However, I want to know if there is a way to show this in this "Show Summaries" article. For example, when you have NSString, it just shows you a line in the "Content" panel without any extra effort from you.

And am I also doing this for my objects? It will save me so much time :)

Thanks guys.

Edit Thanks to the comment of Martin R, I managed to get what I wanted :) Link

+7
source share
1 answer

Basically, you can use a python script as shown below to get any custom resume associated with any object

 # filename : customSummaries.py import lldb def someClass_summary(valueObject, dictionary): # get properties from object ivar1 = valueObject.GetChildMemberWithName('_ivar') ivar2 = valueObject.GetChildMemberWithName('_ivar2') # convert values into python intrinsics error = lldb.SBError() var1 = ivar1.GetData().GetFloat(error, 0) var2 = ivar2.GetData().GetDouble(error, 0) # string generation we're gonna use for the summaries valueRepr1 = str(var1) valueRepr2 = str(var2) return 'value1= ' + valueRepr1 + ', value2= ' + valueRepr2 # this function gets called by the lldb as this script is imported def __lldb_init_module(debugger, dict): # this adds automatically your summaries as the script gets imported debugger.HandleCommand('type summary add Class -F customSummaries.someClass_summary') 

To load custom bulletins while lldb is running, you must import the script above by running the command script import /path/to/customSummaries.py and that’s it.

+1
source

All Articles