LoginSignup
8
7

More than 5 years have passed since last update.

Objective-Cで値型を文字列に変換するときに少し簡単な方法

Posted at
NSInteger num = 3;
// 普通はこう書くはず 
NSString* str1 = [NSString stringWithFormat:@"%d", num];
// こう書ける
NSString* str2 = @(num).stringValue;

コンパイル後、ほとんどのケースで問題にならない程度に差は出るかもしれないけど、意味的にも分かりやすくなって、下の書き方が好み。

8
7
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
8
7