Reputation: 231
I'm trying to debug an iOS app and I'm having problems with lldb in the simulator. Calling class methods doesn't seem to work. Instance methods work fine.
(lldb) po Category
<no result>
(lldb) po [Category class]
error: Couldn't prepare the expression for execution in the target
(lldb) po self
(TagsTableViewController *) $5 = 0x085585a0 <TagsTableViewController: 0x85585a0>
I've tried the 4.3 and 5.1 simulators but both exhibit the same issues.
Everything works fine when debugging on a device.
Upvotes: 15
Views: 3235
Reputation: 4444
Adding this to expand on the accepted answer...
If you're trying to assign a new value to a variable in lldb like I was instead of just printing out the value then do something like this...
expr self.myArray = (NSArray*)[[(Class)objc_getClass("NSArray") class] arrayWithObjects:@"valueOne",@"valueTwo",@"etc",nil]
Upvotes: 0
Reputation: 33406
This works. Thanks to @devioustree who answered in a comment above.
Basic command is structured like this:
po [(Class)objc_getClass("ClassName") class]
To invoke someClassMethodHere
:
po [[(Class)objc_getClass("ClassName") class] someClassMethodHere]
Upvotes: 18