gpt4 book ai didi

swift - NSDateComponentsFormatter 输出在构建之间有所不同

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

我有一段代码,显示一个关于窗口,时间间隔以秒为单位,应该格式化为分钟或小时。当我在本地构建和测试时它工作正常,但 Mac App Store 上的版本仅显示以秒为单位的时间。知道这是为什么吗?

// Seconds between UI update
var updateInterval = 300.0 {
didSet {
log("Update interval changed to \(updateInterval)")
NSUserDefaults.standardUserDefaults().setDouble(updateInterval, forKey: settingsKey)
startTimer()
}
}

@IBAction func showAbout(sender: NSMenuItem) {
let formatter = NSDateComponentsFormatter()
formatter.unitsStyle = .Full
formatter.allowedUnits = [.Minute, .Hour]
//formatter.calendar = nil // Disable localization

// Use the configured formatter to generate the string.
let updateIntervalTimeString = formatter.stringFromTimeInterval(updateInterval)

let alert = NSAlert()
alert.addButtonWithTitle(NSLocalizedString("OK", comment: "Ok button on about screen"))

alert.messageText = NSLocalizedString("ABOUT", comment: "About screen")

let infoString =
NSLocalizedString("ABOUT_INFO_1", comment: "App name") + "\n\n" +
NSLocalizedString("ABOUT_INFO_2", comment: "Update interval info") +
"\(updateIntervalTimeString!)" + "\n\n" +
NSLocalizedString("ABOUT_INFO_3", comment: "Copyright notice")
alert.informativeText = infoString


alert.alertStyle = NSAlertStyle.InformationalAlertStyle

alert.runModal()
}

最佳答案

我刚刚注意到,如果我从 App Store、Spotlight 或 Launchpad 启动应用程序,行为会有所不同。因此,我删除了所有二进制文件并从商店再次下载了该应用程序,现在时间显示正确了。

关于swift - NSDateComponentsFormatter 输出在构建之间有所不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38451020/

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