How to make NSURL variable is nil when parsed from null String?
ios, nsurl
Solution
How about:
NSString *tmpURL = nil;
NSURL *url = tmpUrl ? [NSURL URLFromString:tmpURL] : nil;
Problem
I'm a newbie in iOS development. Sometimes my API server returns a `nil` value. This is raising an error when I try to create a `NSURL` instance. Here is the condition: ``` NSString *tmpURL = nil; NSURL *url = [NSURL URLFromString:tmpURL]; ``` In this condition, it will make the app crash. I just want to make the `url` variable nil, not raise an error.