系统切换到阿拉伯语网络返回的数字为啥解析后,也成阿拉伯语了呢????
po tmp?.publishTime▿ Optional
(lldb) po vlaue["publishTime"]▿ Optional
taor4pac1#
在ExtendCustomType.swift文件中170行代码:if let rawValue = getRawValueFrom(dict: _dict, property: propertyDetail, mapper: mapper) {if let convertedValue = convertValue(rawValue: rawValue, property: propertyDetail, mapper: mapper) {assignProperty(convertedValue: convertedValue, instance: instance, property: propertyDetail)continue}}
po rawValue4(lldb) po convertedValue▿ Optional
wqnecbli2#
找到报错的问题了extension String: _BuiltInBasicType {static func _transform(from object: Any) -> String? {switch object {case let str as String:return strcase let num as NSNumber:// Boolean Type Insideif NSStringFromClass(type(of: num)) == "__NSCFBoolean" {if num.boolValue {return "true"} else {return "false"}}return formatter.string(from: num)case _ as NSNull:return nildefault:return "(object)"}}}就是这句 formatter.string(from: num) 在阿拉伯语中num传入数字,会返回阿拉伯语(lldb) po num1552470694000(lldb) po formatter.string(from: num)▿ Optional
pbpqsu0x3#
文件:BuiltInBasicTypefileprivate let formatter: NumberFormatter = {let formatter = NumberFormatter()formatter.usesGroupingSeparator = falseformatter.numberStyle = .decimalformatter.maximumFractionDigits = 16//强行使用英语模式formatter.locale = NSLocale(localeIdentifier: "en_US") as Localereturn formatter}()
3条答案
按热度按时间taor4pac1#
在ExtendCustomType.swift文件中170行代码:
if let rawValue = getRawValueFrom(dict: _dict, property: propertyDetail, mapper: mapper) {
if let convertedValue = convertValue(rawValue: rawValue, property: propertyDetail, mapper: mapper) {
assignProperty(convertedValue: convertedValue, instance: instance, property: propertyDetail)
continue
}
}
po rawValue
4
(lldb) po convertedValue
▿ Optional
多么诡异的代码????
wqnecbli2#
找到报错的问题了
extension String: _BuiltInBasicType {
static func _transform(from object: Any) -> String? {
switch object {
case let str as String:
return str
case let num as NSNumber:
// Boolean Type Inside
if NSStringFromClass(type(of: num)) == "__NSCFBoolean" {
if num.boolValue {
return "true"
} else {
return "false"
}
}
return formatter.string(from: num)
case _ as NSNull:
return nil
default:
return "(object)"
}
}
}
就是这句 formatter.string(from: num) 在阿拉伯语中num传入数字,会返回阿拉伯语
(lldb) po num
1552470694000
(lldb) po formatter.string(from: num)
▿ Optional
pbpqsu0x3#
文件:BuiltInBasicType
fileprivate let formatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.usesGroupingSeparator = false
formatter.numberStyle = .decimal
formatter.maximumFractionDigits = 16
//强行使用英语模式
formatter.locale = NSLocale(localeIdentifier: "en_US") as Locale
return formatter
}()