How to change NSURL variable value while debugging with LLVM in XCode using expr command?
ios, lldb
Solution
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]
Problem
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.