Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum RawJSON: Codable {
- case number(Double)
- case string(String)
- case bool(Bool)
- // case dictionary([String: RawJSON])
- // case array([RawJSON])
- case `nil`
- }
- let RAWJSONArray = [RawJSON.string("A"),RawJSON.string("B"),RawJSON.string("C")]
- var arrayString : [String] = []
- for item in RAWJSONArray {
- if case let .string(stringValue) = item {
- arrayString.append(stringValue)
- }
- // OR
- if case .string(let stringValue) = item {
- arrayString.append(stringValue)
- }
- // OR
- switch item {
- case .string(let stringValue):
- arrayString.append(stringValue)
- default:
- break
- }
- }
- print(arrayString)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement