How do I "Unwrap" an objc nullable variable?

时间:2018-07-24 10:08:49

标签: objective-c nullable non-nullable

Consider this code:

NSURL* url = [NSURL URLWithString:...];

This returns a nullable NSURL, which I want to use here:

[[UIApplication sharedApplication] openURL:url
                                       options:nil
                             completionHandler:nil];

But alas, openURL requires a non-null url and outputs this warning:

Null passed to a callee that requires a non-null argument

How can this be solved?

0 个答案:

没有答案