gpt4 book ai didi

ios - 以编程方式更新 info.plist 中的值

转载 作者:搜寻专家 更新时间:2023-10-31 22:19:28 26 4
gpt4 key购买 nike

<分区>

我在我的 info.plist 中有一个名为 radiusDistance 的值,我正在尝试更改它,我尝试使用此代码但它不会更改该值

let path = Bundle.main.path(forResource: "Info", ofType: "plist")!
var dict = NSDictionary(contentsOfFile: path) as! [String: AnyObject]


let radiusDistance = dict["radiusDistance"]
print("radiusDistance",radiusDistance as Any)
let value = Int(5)


do{
dict.updateValue(value as AnyObject, forKey: "radiusDistance")
try path.write(toFile: path, atomically: false, encoding:String.Encoding.utf8)
}
catch let error as NSError{
print("something went horribly wrong\(error.debugDescription)")
}

一切都在运行,但是当我返回我的 info.plist 时没有任何变化,并且值保持为“0”

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com