0

Xcode 9.1 斯威夫特 4

如果某个 URL 上仍然不存在属性列表,我正在尝试做一些事情。代码是:

import UIKit

class ViewController: UIViewController {

let urlPers = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent("punterosborrable.plist")
    lazy var infoPunt = try? Data(contentsOf: urlPers)



    override func viewDidLoad() {
        super.viewDidLoad()

        switch infoPunt {
        case nil:
            puntNUM = 1
            puntALG = 1
            puntGEO = 1
            puntDYA = 1
        default:
            puntNUM = try! PropertyListDecoder().decode([Int].self, from: infoPunt!)[0]
            puntALG = try! PropertyListDecoder().decode([Int].self, from: infoPunt!)[1]
            puntGEO = try! PropertyListDecoder().decode([Int].self, from: infoPunt!)[2]
            puntDYA = try! PropertyListDecoder().decode([Int].self, from: infoPunt!)[3]
        }

假设,如果我不向 Url 写入任何内容,infoPunt 的值应该为零。然而,就在运行线路之后

 switch infoPunt {

调试器显示infoPunt.storage = (Data?) some

这是什么意思?infoPunt 此时持有什么价值(或数据)?我认为它应该是零。

提前致谢

4

0 回答 0