Often times we would want to hold some temporary variables when debugging with lldb. We can make use of expression in such cases. An expression, short form e or expr evaluates the given statement. If we use an assignment with a variable starting with $, that variable will be available throughout and can be used in other expressions.

expr NSRange $range1 = NSMakeRange(0, 3);
expr [@"Hi there" substringWithRange:(NSRange)$range1];
(NSTaggedPointerString *) $9 = 0x7a858d27bb2607ed @"Hi "

Since we are in single-line expression mode, there are slight differences in the way the expressions work. We need to cast NSRange. A better option in this case is to use the multi-line expression mode. For that, first enter expr↩ which is followed by a carriage return. The lldb is now in multi-line expression mode where we can enter normal Objective-C (or Swift) code with each line terminated with a semi-colon and an empty line after the final statement will evaluate all the expressions and exit the mode.

expr
Enter expressions, then terminate with an empty line to evaluate:
1 NSRange range = NSMakeRange(6, 5);
2 NSString *str = @"Hello World";
3 [str substringWithRange:range];
4 
(NSTaggedPointerString *) $4 = 0x7a858d42fd26039d @"World"

Multi-line expression with lldb makes debugging much better.