7
4

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.

「’characters’ is deprecated: Please use String or Substring directly」が出てワーニング

Posted at

’characters’ is deprecated: Please use String or Substring directly

Swiftで、こんなワーニングが出た。
やろうとしたことは、String型の定数を一文字ずつのCharacter型配列にしたかった。

let string = "hoge"
let characters = Array(string.characters)

Swift4.0以降?なのか、charactersが持っていたメソッドを、
String自体が持つようになったらしい。

let string = "hoge"
let characters = Array(string)

.countとかでも同様。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?