我需要NSImage
中的contentsOfURL并将其转换为String
。
我有一个conf.txt文件,在该文件中我会保护来自NSImage
的contentsOfURL。
不工作:
写:
for i in 0 ..< RunnerFaces.count {
name = RunnerFaces[i].RunnerName + space
speed = String(RunnerFaces[i].RunnerSpeed) + space
img1 = String(RunnerFaces[i].RunnerImage1) + space
img2 = String(RunnerFaces[i].RunnerImage2) + space
strz = name+speed+img1+img2
str.append(strz)
}
读:
for _ in 0 ..< safedRunner {
name = loadSplit[0]
speed = loadSplit[1]
img1 = loadSplit[2]
img2 = loadSplit[3]
RunnerFaces.append(RunnerFace(RunnerName: name, RunnerSpeed: Double(speed)!, RunnerImage1: NSImage(imageLiteral: img1), RunnerImage2: NSImage(imageLiteral: img2)))
for _ in 0 ..< 4{
loadSplit.removeAtIndex(0)
}
}
写作&amp;阅读仅适用于NSImage
崩溃..