Post

Replies

Boosts

Views

Activity

Reply to Any Idea how to Decode this JSON
You can try it like this:         let demo = """ {"name":"Foo","age":34,"activities":[{"test1":"testing","type":"xyz","three":{"label1":"Testing1","content":[{"mark1":"markTest1","mark2":"markTest2"}]}},{"test2":"Running","type":"zzzz","three":[{"label2":"Testing1"},{"label2":"Testing1"}]}]} """         guard let data = demo.data(using: .utf8) else { return }         let decoded = try? JSONDecoder().decode(TopLevel.self, from: data)         print(decoded?.name) ```
Jul ’20
Reply to Any Idea how to Decode this JSON
The below code should be able to decode that structure. import Foundation // MARK: - TopLevel struct TopLevel: Codable {     let name: String     let age: Int     let activities: [Activity]          enum CodingKeys: String, CodingKey {         case name         case age         case activities     } } // MARK: - Activity struct Activity: Codable {     let test1: String?     let type: String     let three: ThreeUnion     let test2: String?          enum CodingKeys: String, CodingKey {         case test1         case type         case three         case test2     } } enum ThreeUnion: Codable {     case purpleThree(PurpleThree)     case threeElementArray([ThreeElement])          init(from decoder: Decoder) throws {         let container = try decoder.singleValueContainer()         if let x = try? container.decode([ThreeElement].self) {             self = .threeElementArray(x)             return         }         if let x = try? container.decode(PurpleThree.self) {             self = .purpleThree(x)             return         }         throw DecodingError.typeMismatch(ThreeUnion.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Wrong type for ThreeUnion"))     }          func encode(to encoder: Encoder) throws {         var container = encoder.singleValueContainer()         switch self {         case .purpleThree(let x):             try container.encode(x)         case .threeElementArray(let x):             try container.encode(x)         }     } } // MARK: - ThreeElement struct ThreeElement: Codable {     let label2: String          enum CodingKeys: String, CodingKey {         case label2     } } // MARK: - PurpleThree struct PurpleThree: Codable {     let label1: String     let content: [SBContent]          enum CodingKeys: String, CodingKey {         case label1         case content     } } // MARK: - SBContent struct SBContent: Codable {     let mark1: String     let mark2: String          enum CodingKeys: String, CodingKey {         case mark1         case mark2     } }
Jul ’20
Reply to Unsupported Xcode or SDK Version when Uploading with Xcode 12 Beta 3
Same issue here. After archiving I have validated the app and Xcode says that there is no problems. But after uploading I get this error message on mail: ITMS-90562: Invalid Bundle - The app submission can not be successfully recompiled from bitcode due to missing symbols during linking. You can try to reproduce and diagnose such issues locally by following the instructions from: https://developer.apple.com/library/archive/technotes/tn2432/_index.html I have also followed the steps here - https://developer.apple.com/library/archive/technotes/tn2432/_index.html, but all fine - "Rebuild from bitcode" works as it should without any error messages. Created a feedback for it as well, FB8136576.
Jul ’20
Reply to Changing between tab bar and sidebar in swiftUI
Yes, use horizontalSizeClass. Here is an example: struct ContentView: View {          #if os(iOS)     @Environment(\.horizontalSizeClass) private var horizontalSizeClass     #endif          @ViewBuilder var body: some View {                  #if os(iOS)         if horizontalSizeClass == .compact {             AppTabNavigation()         } else {             AppSidebarNavigation()         }         #elseif os(watchOS)         AppTabNavigation()         #elseif os(tvOS)         AppTabNavigation()         #else         AppSidebarNavigation()             .frame(minWidth: 900, maxWidth: .infinity, minHeight: 500, maxHeight: .infinity)         #endif     } }
Jul ’20