如何在Swift中将NSImage contentsOfURL转换为String?

时间:2016-05-30 16:37:22

标签: xcode swift macos nsimage

我需要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崩溃..

0 个答案:

没有答案