如何在 Swift 中调用 NSLocalizedStringWithDefaultValue?
How do I call NSLocalizedStringWithDefaultValue in Swift?
NSLocalizedString
in Objective-C 在 Swift 中有一个简单的函数:
NSLocalizedString(_: comment:)
, but where is the Swift equivalent of Objective-C's NSLocalizedStringWithDefaultValue
?
NSLocalizedString(_: comment:)
根本不是 Swift 函数,它实际上是 NSLocalizedString(_:tableName:bundle:value:comment:)
。 tableName
、bundle
、value
都有default
,所以一般情况下不需要指定。因此,Swift 只有一个函数可以处理各种 Objective-C 本地化宏的所有情况。
func NSLocalizedString(_ key: String,
tableName: String? = default,
bundle: Bundle = default,
value: String = default,
comment: String) -> String
NSLocalizedString
in Objective-C 在 Swift 中有一个简单的函数:
NSLocalizedString(_: comment:)
, but where is the Swift equivalent of Objective-C's NSLocalizedStringWithDefaultValue
?
NSLocalizedString(_: comment:)
根本不是 Swift 函数,它实际上是 NSLocalizedString(_:tableName:bundle:value:comment:)
。 tableName
、bundle
、value
都有default
,所以一般情况下不需要指定。因此,Swift 只有一个函数可以处理各种 Objective-C 本地化宏的所有情况。
func NSLocalizedString(_ key: String,
tableName: String? = default,
bundle: Bundle = default,
value: String = default,
comment: String) -> String