Hi all. I am from the United States, and I understand that insurance most likely will not cover hypnotherapy. Being that it'll be out of pocket, and fairly expensive, I wanted to see if anybody here had any positives or negatives with respect to using hypnotherapy. My main goal with this type of therapy would be to address my focus and memory with regard to my ADHD. Thank you!
So I've got the following code, which seems to work, and I'm wondering if there is a better, cleaner way to approach adding/editing elements in an array.
var category: Category
var idx: Int = -1
switch mode {
case .add:
category = Category()
case .edit(let _category):
category = _category
idx = categoryViewModel.categories.firstIndex(of: _category) ?? idx
}
category.name = categoryName
category.icon = "category-\(categoryIdx)"
category.color = colors[colorIdx]
switch mode {
case .add:
categoryViewModel.categories.append(category)
case .edit:
categoryViewModel.categories[idx] = category
}
I understand I'm not checking idx
to make sure it's not -1
. I'm not concerned about that part right now. It's the overall approach I'm looking for thoughts on.
Thanks!
It was a long time coming.
https://www.avanderlee.com/swift/mainactor-dispatch-main-thread/
MainActor in Swift replaces DispatchQueue.main and ensures tasks are performing on the main thread in a performant manner.
@dohpaz42
@lemmy.world