gpt4 book ai didi

Swift:当前配置的占位符

转载 作者:行者123 更新时间:2023-11-30 13:37:38 25 4
gpt4 key购买 nike

我正在阅读 example用于拥有多个配置并在运行时使用以下 Objective C 代码访问事件配置:

  NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle pathForResource:@"Configuration" ofType:@"plist"];
NSDictionary *config = [NSDictionary dictionaryWithContentsOfFile:path];

用于获取事件配置值的 @"Configuration" 的 Swift 等效项是什么?

这不起作用:

var myDict: NSDictionary?
if let path = NSBundle.mainBundle().pathForResource(@"Configuration", ofType: "plist") {
myDict = NSDictionary(contentsOfFile: path)
}

最佳答案

只需删除@,它就会起作用:

var myDict: NSDictionary?
if let path = NSBundle.mainBundle().pathForResource("Configuration", ofType: "plist") {
myDict = NSDictionary(contentsOfFile: path)
}

关于Swift:当前配置的占位符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35906343/

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