使用 '!' 时出现问题将在未来的版本中删除
Problem Using '!' will be removed in a future release
if let encodingName = response?.textEncodingName as CFString! , convertedEncoding == nil {
convertedEncoding = String.Encoding(rawValue: CFStringConvertEncodingToNSStringEncoding(
CFStringConvertIANACharSetNameToEncoding(encodingName))
)
对我的问题有什么想法吗??
只需使用
if let encodingName = response?.textEncodingName as? CFString , convertedEncoding == nil {
convertedEncoding = String.Encoding(rawValue: CFStringConvertEncodingToNSStringEncoding(
CFStringConvertIANACharSetNameToEncoding(encodingName)))
}
此问题是由于转换为 CFString!
引起的
if let encodingName = response?.textEncodingName as CFString! , convertedEncoding == nil {
convertedEncoding = String.Encoding(rawValue: CFStringConvertEncodingToNSStringEncoding(
CFStringConvertIANACharSetNameToEncoding(encodingName))
)
对我的问题有什么想法吗??
只需使用
if let encodingName = response?.textEncodingName as? CFString , convertedEncoding == nil {
convertedEncoding = String.Encoding(rawValue: CFStringConvertEncodingToNSStringEncoding(
CFStringConvertIANACharSetNameToEncoding(encodingName)))
}
此问题是由于转换为 CFString!