0
0

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.

エラーCannot convert value of type 'Int32' to specified type 'Int'の修正

Posted at

objective-cを変換した時にintのエラーが出たのでその対処法メモ

エラーメッセージ

Cannot convert value of type 'Int32' to specified type 'Int'

Int32をIntに変換できないよ

int32とintの何が違うのか

Intは32bit環境だとint32になって64bit環境だとint64になる
つまりint32もint64と同じIntということ。

しかし、swiftではIntとして使うにはキャストしないといけない

objcで大丈夫だった配列にintを入れるところもswiftだと以下のようなエラーになる
["A","B","C"][Int32の番号]

 Cannot subscript a value of type '[String]' with an index of type 'Int32'

この場合は以下のようにすればおk

["A","B","C"][Int(int32の番号)]
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?