Setting a temp (user-defined) variable in lldb.

Being a complete amateur is why I keep forgetting this simple syntax, I suppose.

(lldb) expr int $bob = 5;
(lldb) print bob
error: use of undeclared identifier 'bob'
error: 1 errors parsing expression
(lldb) print $bob
(int) $bob = 5

It really is that simple. *thumps side of head*

A more complex example. I put a break point in my view controller's viewDidLayoutSubviews and did this.

(lldb) expr NSUInteger $tmpArr[2] = {0,2};
(lldb) expr NSIndexPath* $tmpIndex = [NSIndexPath indexPathWithIndexes:$tmpArr length:2];
(lldb) expr UITableViewCell* $tmpCell = [self.tableView cellForRowAtIndexPath:$tmpIndex];
(lldb) po $tmpCell
$tmpCell = 0x0fc29af0 <UITableViewCell: 0xfc29af0; frame = (0 0; 180 44); text = 'empty'; autoresize = W; layer = <CALayer: 0xfc29c70>>
(lldb) po $tmpCell.imageView 
$0 = 0x0fc2a9b0 <UIImageView: 0xfc2a9b0; frame = (0 0; 0 0); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xfc2aa10>>

I didn't find the value I was looking for, but that's not the point.

No comments:

Post a Comment