I am facing an issue with "NSURL URLWithString" method,
I am expecting to get nil while using the above method if the url string is invalid. But its returning empty value instead.
I have attached the code sample below.
NSString *sampleURLString = @"";
NSURL *sampleURL = [NSURL URLWithString:sampleURLString];
NSLog(@"Sample url string : %@", sampleURLString);
NSLog(@"Sample url : %@", sampleURL);
Additional information:
- I am using XCode Version 8.1.
- I have also tested in iOS version (8,9,10) in device and simulator.
- As of now I have handled this by using "canOpenURL" to check the resulted NSURL and avoided further execution. But I need to know why this issue occurs.