0
0

More than 3 years have passed since last update.

Objective-Cでの三項演算子

Posted at

三項演算子ブーム

iOSを書いていると三項演算子ブームがやってきませんでしょうか?

変数に入れたい値がnilだったら代わりのテキストを入れるというものです。

Objective-Cだとこう書きます。

NSString *str = nil;
NSString *string = str ? str: @"nilだったので代入";

変数が複雑になるとちょっと書きづらいですが、基本的な構造は一緒なので落ち着いて書きましょう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0