gpt4 book ai didi

swift - 如何在 Xcode 中从 info.plist 中获取不带双引号的字符串值

转载 作者:搜寻专家 更新时间:2023-11-01 06:58:57 24 4
gpt4 key购买 nike

我目前正在使用 Xcode 开发 iOS 项目。出于安全目的,我编写了 .xccconfile 并将其从版本控制中删除。我不需要以这种方式提交一些 api 代码。 .xccconfig 文件就像

API_KEY = "abcdefg"

然后,我像这样在 info.plist 中设置 key

info.plist

问题是当我从 info.plist 中获取值时,返回的值带有双引号。

Bundle.main.object(forInfoDictionaryKey: "API_KEY") as! String
=> "abcdefg"

我想得到值 abcdefg,它不带双引号。

我通过

删除 "解决方法
if let str = self.object(forInfoDictionaryKey: key) as? String {
return str.replacingOccurrences(of: "\"", with: "")
}

我不想这样做。

最佳答案

只需删除配置文件中的引号

API_KEY = abcdefg

关于swift - 如何在 Xcode 中从 info.plist 中获取不带双引号的字符串值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51737658/

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