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!