UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SwiftUI coding roadblock

Forums > SwiftUI

Hi guys, I'm trying to develop my first app, but have a coding problem I can't seem to solve despite searching through forums and SwiftUI tutorials. I'm building a radiology teaching app and need to sort different pathology and anatomy into different categories, depending on the imaging study. I thought I could solve this by using multiple dictionaries but encounter an error when I try to use more than one Category declaration. I tried subdividing the items into sections and listing them as arrays in JSON data format, but this did not work either. "var chests: [Chest] = load("chest.json") var chestcategories: [String: [Chest]] { Dictionary( grouping: chests, by: { $0.category.rawValue } ) }" "[ { "id": 0, "chestname": "Heart", "chestimage": "heart", "category": "anatomy", "description": "Size, Shape, Margins", "sectioncategory": "Chest" },

{
    "id": 1,
    "chestname": "Lungs",
    "chestimage": "lungs",
    "category": "anatomy",
    "description": "Airspace opacity, Pleural effusion, Pneumothorax",
    "sectioncategory": "Chest"
},

{
    "id": 2,
    "chestname": "Airway",
    "chestimage": "airway",
    "category": "anatomy",
    "description": "Caliber, Narrowing (Symmetric vs Asymmetric), Tracheal deviation",
    "sectioncategory": "Chest"
},

{
    "id": 3,
    "chestname": "Diaphragm",
    "chestimage": "diaphragm",
    "category": "anatomy",
    "description": "Is there air under the diaphragm?, Diaphragmetic hernias or defects, Shape (Right hemidiaphragm should be higher than left)",
    "sectioncategory": "Chest"
},"

In this example, I'd like to be able to sort and selectively display data based on both the category and sectioncategory variables. Thanks guys!

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.