Post

Replies

Boosts

Views

Activity

Reply to Modifying an associated value of an existing enum instance
Thank you @DTS Engineer , this is what the rest of the enum cases, and its computed properties, look like: enum FilterItem: Hashable { case work(isSelected: Bool) case family(isSelected: Bool) case health(isSelected: Bool) case social(isSelected: Bool) case energetic(isSelected: Bool) case tired(isSelected: Bool) case restless(isSelected: Bool) case heavy(isSelected: Bool) case numb(isSelected: Bool) case calm(isSelected: Bool) case tense(isSelected: Bool) case light(isSelected: Bool) case racing(isSelected: Bool) case focused(isSelected: Bool) case confused(isSelected: Bool) case overthinking(isSelected: Bool) case blank(isSelected: Bool) case reflective(isSelected: Bool) case head(isSelected: Bool) case neck(isSelected: Bool) case chest(isSelected: Bool) case shoulders(isSelected: Bool) case arms(isSelected: Bool) case solarPlexus(isSelected: Bool) case stomach(isSelected: Bool) case lowerAbdomen(isSelected: Bool) case legs(isSelected: Bool) case wholeBody(isSelected: Bool) var filterName: String { switch self { case .work: return "Work" case .family: return "Family/Relationships" case .health: return "Health/Physical Wellbeing" case .social: return "Social" case .energetic: return "Energetic/Alert" case .tired: return "Tired/Fatigued" case .restless: return "Restless/Fidgety" case .heavy: return "Heavy/Weighted Down" case .numb: return "Numb/Tingling" case .calm: return "Calm/Relaxed" case .tense: return "Tense/Tight" case .light: return "Light/Buzzing" case .racing: return "Racing/Fast" case .focused: return "Focused/Clear" case .confused: return "Confused/Foggy" case .overthinking: return "Overthinking/Spiralling" case .blank: return "Blank" case .reflective: return "Reflective/Meditative" case .head: return "Head" case .neck: return "Neck/Throat" case .chest: return "Chest/Heart" case .shoulders: return "Shoulders" case .arms: return "Arms/Hands" case .solarPlexus: return "Solar Plexus" case .stomach: return "Stomach/Gut" case .lowerAbdomen: return "Lower Abdomen/Core" case .legs: return "Legs/Feet" case .wholeBody: return "Whole Body" } } var category: EmotionFiltersViewController.Section { switch self { case .work: return .lifeEvents case .family: return .lifeEvents case .health: return .lifeEvents case .social: return .lifeEvents case .energetic: return .physicalSensations case .tired: return .physicalSensations case .restless: return .physicalSensations case .heavy: return .physicalSensations case .calm: return .physicalSensations case .tense: return .physicalSensations case .light: return .physicalSensations case .numb: return .physicalSensations case .racing: return .mindThoughts case .focused: return .mindThoughts case .confused: return .mindThoughts case .overthinking: return .mindThoughts case .blank: return .mindThoughts case .reflective: return .mindThoughts case .head: return .bodyLocation case .neck: return .bodyLocation case .chest: return .bodyLocation case .shoulders: return .bodyLocation case .arms: return .bodyLocation case .solarPlexus: return .bodyLocation case .stomach: return .bodyLocation case .lowerAbdomen: return .bodyLocation case .legs: return .bodyLocation case .wholeBody: return .bodyLocation } } var isSelected: Bool { switch self { case .work(let isSelected): return isSelected case .family(let isSelected): return isSelected case .health(let isSelected): return isSelected case .social(let isSelected): return isSelected case .energetic(let isSelected): return isSelected case .tired(let isSelected): return isSelected case .restless(let isSelected): return isSelected case .heavy(let isSelected): return isSelected case .calm(let isSelected): return isSelected case .tense(let isSelected): return isSelected case .light(let isSelected): return isSelected case .numb(let isSelected): return isSelected case .racing(let isSelected): return isSelected case .focused(let isSelected): return isSelected case .confused(let isSelected): return isSelected case .overthinking(let isSelected): return isSelected case .blank(let isSelected): return isSelected case .reflective(let isSelected): return isSelected case .head(let isSelected): return isSelected case .neck(let isSelected): return isSelected case .chest(let isSelected): return isSelected case .shoulders(let isSelected): return isSelected case .arms(let isSelected): return isSelected case .solarPlexus(let isSelected): return isSelected case .stomach(let isSelected): return isSelected case .lowerAbdomen(let isSelected): return isSelected case .legs(let isSelected): return isSelected case .wholeBody(let isSelected): return isSelected } } }
Jul ’25
Reply to Trying to Apply Content Configuration on a UICollectionReusableView
UICollectionReusableView has no property called contentConfiguration. Rather than use UICollectionReusableView as the cell type in the supplementary registration, I used UICollectionViewCell. I also used the API for the UIListContentConfiguration to modify the appearance of the text of the primary and secondary titles to get the larger appearance of the header that I want and the contrast in the text colours of the primary and secondary labels. My code looks like this now: let headerRegistration = UICollectionView.SupplementaryRegistration<UICollectionViewCell>(elementKind: UICollectionView.elementKindSectionHeader) { header, elementKind, indexPath in // Header configuration is handled in the header's init var configuration = UIListContentConfiguration.plainHeader() configuration.text = "Current Emotional State" configuration.textProperties.font = .systemFont(ofSize: 20, weight: .medium) configuration.textProperties.color = .label configuration.secondaryText = "What best describes how you're feeling right now?" configuration.secondaryTextProperties.font = .systemFont(ofSize: 17, weight: .regular) header.contentConfiguration = configuration }
Topic: UI Frameworks SubTopic: UIKit
Jul ’25
Reply to Is super.init(frame: CGRect) the designated initialiser for a UICollectionViewCell class?
According to the documentation regarding UIView, the init(frame: CGRect) is the designated initialiser for UIView when I instantiate a UIView object programatically. Additional, there's an article on Medium by Abdul Ahad titled "Different types of Init in Swift" (I can't link to this article here unfortunately as the platform rules prohibit it), goes into detail about the various types of initialisers and explains that init(frame: CGRect) is also the designated initialiser for UICollectionViewCell. required init?(coder: NSCoder) on the other hand creates a view from data in an unarchiver. And according to "Passing data by using -required init decoder" also on Medium, we use the decoder in this instance to tell Xcode that we aren't relying on storyboard to instantiate the view (by implementing a fatalError("not using storyboard")) message inside the init?(coder:) method.
Topic: UI Frameworks SubTopic: UIKit
Jul ’25