xcode - How to let lldb print the description written in an Objective-C category -
an incredible tip debugging constraint issues print constraint`s id in lldb
but should let lldb print category`s description?
@interface nslayoutconstraint (description) @end @implementation nslayoutconstraint (description) -(nsstring *)description { return [nsstring stringwithformat:@"id: %@, constant: %f", self.identifier, self.constant]; } @end help appreciated :)
you can use description method in 2 ways. one, if in code in app somewhere do:
nslog(@"my object: %@", my_object); then %@ specifier print nsstring returned "description" method of object.
another way in debugger:
lldb (and gdb before it) has command called po - short print-object. it's job take expression, evaluate it, interpret result (in case of objc) nsobject , send object description method.
so in debugger can call
(lldb) po object and printout.
one detail, though: po first checks if object responds debugdescription , call in preference description. if extending object implements debugdescription (some kit objects this) po show result of debugdescription method, not description.
Comments
Post a Comment