LoginSignup
23
23

More than 5 years have passed since last update.

String.substring〜の使い方

Posted at
let str = "substring"
str.substringToIndex(3)

このコードはコンパイルエラーになる。

substringToIndex の引数は String.Index なので、
NSString の substringToIndex を使うか、
advance() で String.Index を作るか、
次のどちらかの方法をとる。

let str = "substring"
(str as NSString).substringToIndex(3)
str.substringToIndex(advance(str.startIndex, 3))
23
23
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
23
23