3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

XCode8で「Implicit conversion loses integer precision: 'NSUInteger' (aka 'unsigned long') to 'int'」警告

Posted at

XCode8にて、「Implicit conversion loses integer precision: 'NSUInteger' (aka 'unsigned long') to 'int'」警告が出た場合あります。
その原因は、NSIntegerの持ちうる値が32bitか64bitかは処理系依存だから。
int型変数に値を代入する時はプログラマが明示的にint(32bit)と宣言する必要がある。
そして、NSIntegerはlong型 "または" int型をtypedefしたもの。

例えば、以下のような場合、警告がある。
変更前:
iTotalQuestion = [appDelegate.questions count];

変更後:
iTotalQuestion = (int)[appDelegate.questions count];

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?