LoginSignup
5
5

More than 5 years have passed since last update.

Swift 指定位置の文字列を置換する

Posted at

swiftで指定位置の文字を置換。

var str:NSString = "ABCDEFGHIJKLMNOP"
var pos = NSMakeRange(4,4) // 位置
println(str.stringByReplacingCharactersInRange(pos, withString: "hoge"))

NSString型でないとエラーになってしまいますのでご注意を。

5
5
2

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