我有一个文本文件。它只包含"你好"但这个比较并没有正确起作用。我认为问题是读取变量,因为我试过insiate string包含hello并且它可以工作。
do {
readStringProject = try String(contentsOfFile: fileURLProject!, encoding: String.Encoding.utf8)
} catch let error as NSError {
print("Failed reading from URL: \(fileURL), Error: " + error.localizedDescription)
}
var st: String!
st = "hello"
let st1 : String!
st1 = String (readStringProject)
if st1 == st {
print("same")
} else {
print("not same")
}