Optional Data -> String Conversion
Prefer failable String(bytes:encoding:)
initializer when converting Data
to String
- Identifier:
optional_data_string_conversion
- Enabled by default: Yes
- Supports autocorrection: No
- Kind: lint
- Analyzer rule: No
- Minimum Swift compiler version: 5.0.0
- Default configuration:
Key Value severity warning
Non Triggering Examples
String(data: data, encoding: .utf8)
String(bytes: data, encoding: .utf8)
String(UTF8.self)
String(a, b, c, UTF8.self)
String(decoding: data, encoding: UTF8.self)
Triggering Examples
String(decoding: data, as: UTF8.self)