【发布时间】:2016-12-11 02:29:28
【问题描述】:
从 udacity 课程我正在尝试下面的代码
let password = "Meet me in St. Louis"
let newPassword = password.replacingOccurrences(of: "e", with: "3")
这是给的
Playground execution failed: Introduction.xcplaygroundpage:31:19: error: value of type 'String' has no member 'replacingOccurrences'
let newPassword = password.replacingOccurrences(of: "e", with: "3")
^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
强制我必须使用
let password = "Meet me in St. Louis"
let newPassword = password.stringByReplacingOccurrencesOfString("me", withString: "ss")
任何线索为什么会出现这个错误?我正在使用 swift 2.2 版
【问题讨论】:
-
让 Swift 2.2 的 newPassword = password.stringByReplacingOccurrencesOfString("e",withString:"3")