3

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.

Community
  • 1
  • 1
SFeng
  • 2,226
  • 1
  • 19
  • 16

2 Answers2

7

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]
HKTonyLee
  • 3,111
  • 23
  • 34
0

for Swift 5:

expr url = URL(string:"https://www.example.com")! 
Pitoneux
  • 1
  • 4