Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change NSURL variable value while debugging with LLVM in XCode using expr command?

Tags:

ios

lldb

In Xcode, LLDB could change variable value by expr command while debugging(see How to change variables value while debugging with LLVM in XCode?). I used this method to change a string value successfully, but when I change a NSURL variable to a new instance, I got an error:

(lldb) expr url = [NSURL URLWithString:@"www.example.com"];
error: no known method '+URLWithString:'; cast the message send to the method's return type
error: 1 errors parsing expression

How could I change url to a new value? Thanks.

like image 558
SFeng Avatar asked Dec 04 '25 03:12

SFeng


1 Answers

You may try explicitly casting, i.e.

expr url = (NSURL *)[NSURL URLWithString:@"www.example.com"];

Because the LLDB sometimes cannot obtain the return type. For example,

// You should specify the return type here:
expr (int)[UIApplication version]

// instead of
expr [UIApplication version]
like image 170
HKTonyLee Avatar answered Dec 06 '25 15:12

HKTonyLee