Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はiOS開発の初心者です。APIサーバーが値を返すことがありnilます。インスタンスを作成しようとすると、これによりエラーが発生しNSURLます。
nil
NSURL
条件は次のとおりです。
NSString *tmpURL = nil; NSURL *url = [NSURL URLFromString:tmpURL];
この状態では、アプリがクラッシュします。urlエラーを発生させるのではなく、変数をnilにしたいだけです。
url
どうですか:
NSString *tmpURL = nil; NSURL *url = tmpUrl ? [NSURL URLFromString:tmpURL] : nil;