Tuesday, December 17, 2024

 I have taken a long-ish break from 100 Days of SwiftUI to do a couple of related things.  I am trying to really nail done SwiftData so I am doing the SwiftData by Example Collection.  Also, using what I have learned, thus far, I have created an app from a long languishing idea that has been waiting for me to turn it into an app on the AppStore.  I completed the business logic two years ago, but needed the time and SwiftUI experience to make it happen in a way that would make me happy.  It is in Test Flight now.  Every part of creating the app just flowed.  I knew what I wanted to do.  I knew how to execute each part of the app or knew where to get the info.  For this app, I had reached critical mass in my progress and I needed to create it.  I'll get back to learning SwiftUI in a week.

One more thing I discovered while doing this new app was how to get the Section Header to stay on the screen when scrolling the contents of the section.  Much like the secret of how to get buttons to recognize button taps when they are in a list row, you just had to somehow know or find the secret.  It was not discoverable.

var body: some View {

        List {

            Section(header: SectionHeaderView(totalusers.count)) {

                ForEach(users) { user in

                    ListRowView(user: user)

                }

                .onDelete() { indexes in

                    users.remove(atOffsets: indexes)

                }

            }

        }

        .listStyle(.plain)

    }

}

Again, it was changing the style of a UI View.  Here, in order for the Section Header to be "sticky" and stay in view which scrolling the list up, the style of the list had be .listStyle(.plain).


Why this is?  I believe it is because of a complicated interaction with the default .insetGrouped listStyle support of sidebars on iPads and Macs.  That's all I know.  You need to apply this one non-default listStyle and then it works.  Magic.

(UL10)


Sunday, December 8, 2024

I have submitted a few dozen radars/feedbacks over the years since Swift was first released. While some have gotten more traction than others, the one's that really find honest to gosh broken functionality get fixed. The bug I detailed here was reported on to Apple on 11 Nov in Feedback: FB15764538. On 3 Dec, I was notified by Apple that they believe it was fixed in Xcode 16.2 Beta 3 and they asked me to test it. I did and they did indeed fix the issue. Success. Effort justified.

import SwiftUI

struct ContentView: View {
  @State private var text = ""
  var body: some View {
    VStack {
      TextField("Enter Text Here", text: $text)
        .foregroundStyle(text.count > 3 ? .primary : Color.red)
      Text(text)
        .foregroundStyle(text.count > 3 ? .primary : Color.red)
    }
  }
}

This is the simple test case I sent Apple detailing the problem with TextField.

We developers don't work for Apple, but we are a critical part of the app development eco-system. The folks who produce the developer tools and the libraries are not perfect but they try really hard to get as close as they can to that goal. We, 3rd party developers and hobbiests, play an important role in helping close that gap even more. 

And just in case you think that you don't need to report bugs like these, that someone else will, don't bet on it. This Feedback was marked as: 

           Recent Similar Reports:None 

While a bunch of reports on the same bug from multiple developers can help draw more attention to the really hard to find or solve problems, even more powerful is a simple bit of sample code that clearly reproduces the problem - pure gold for the engineer trying to find the issue. Be clear, be concise, be polite. 

I feel great when a bug like this gets fixed. I helped someone elses app shine because it wasn't hobbled by this bug. I helped another developer not waste hours tracking this same bug down in order to find a work-around. I helped an Apple Developer Tools Engineer get a little closer to their goal and feel justifiable pride in producing a product just a little better than it was the day before.

Also, thank you to @MartinAtElitappar on the HackingWithSwift+ forums who helped validate my conclusion that this was a bug and who encouraged me to report it to Apple.

(LU9)

Sunday, December 1, 2024

Back to Work

I took some extra time after family departed before I got back into 100 Days of SwiftUI.  For those keeping track, I am on Day 54.  I took extra time with the challenge on Day 47, Habit Tracker, not because it was difficult, but because I really wanted to pull together the concepts and try a couple of new things.  

One of the new things was adding buttons views in a list row. Turns out there is a secret to making this work. You have to read the documentation or get a bit lucky on StackExchange.  I really don't know how people coded before the internet.  Oh yeah, I remember.  I RTFM.  Anyhow, the problem was that tapping on the button in the list row, just selected the row.  The button press was not detected.  Turns out for the button press to be recognized, the .buttonStyle must be anything other than .automatic, the default.  My thanks to Ramis who provided the answer.  It has 312 likes (at the moment) so I think a great many others have searched for this answer.

The other issue was crafting an input screen that also served as a detail view.  The former was reached by an add button, sliding up a sheet.  The latter via tapping on the list row of an existing habit that was a NavigationLink to a detail view.  The two cases were differentiated by passing in the selectedHabit.  In the case of adding a new habit, the selectedHabit was nil.  In hindsight they certainly could have been two different views, but I enjoyed working out how to do it with a single Swift view.


Anyhow, I'm currently getting an introduction to SwiftData on Day 54 and enjoying replacing CoreData with all its quirks.  I'm too new to SwiftData, but I'm sure I'll be cursing its particular quirks soon enough.

 (LU8)

Friday, November 22, 2024

About to Take a Break

It has been a grueling week and by grueling I mean a pleasantly full week.  I have maintained my goal of trying to fit three days of SwiftUI into each day.  I have tried not to compromise learning the material to keep that pace.  I have reviewed the material, multiple times for items that are new and strange to me.  I have done the challenges completely, always attempting them on my own, but greatly appreciating that videos by Paul Hudson exist for HWS+ members.  I have spent time adding my own flairs to the apps where they have captivated me.  I have also been working with my programming/study partner.  I am so glad that we are chatting regularly again and that he is just as enthralled by Paul's lessons, as I am.

With a productive few days behind me, I'll now be taking a break.  Family is in town for the upcoming Holiday and my time will be devoted to them.  For those of you who celebrate it, I wish you a very Happy Thanksgiving.

(LU7)

Tuesday, November 19, 2024

Connected Again

As of last night, it had been two weeks since I had heard from my programming/study partner.  That was the Monday right before the election.  Between his interview scheduled on Wednesday and the results of the election, I figured he might be struggling and needing to regroup, so I let him know I was here when he was ready to reach out and to take care of himself.  I finally checked on him again via text to ask for proof of life and again let him know I was here for him.  He called me right back and, as I suspected, he was really hurting after the election results.  We chatted for a while and then agreed to work together tonight.  

After I got totally sidetracked the previous weekend tracking down an Apple bug, I made relatively slow but steady progress through the following week and weekend.  I am currently on day 40 of 100 Days of SwiftUI.  While way behind my original schedule, I have made some solid progress.  I especially like my resulting Word Scramble game, project 6.  


I made a great many tweaks, along the way and really have just one more major bug to resolve.  I generate all possible words that are makable from the source word with length 3-8.  I then run that list through Apple's UITextChecker() to determine actual legitimate English words.  This can take a couple of seconds at the start of every new game.  I need to make sure that happens completely in the background so I don't block the main thread.  Also, for the record one more time, UITextChecker() sucks.  It is reasonably fast, but it is really really bad at doing its one purpose, determining if a word is an actual word.

Anyway, after Word Scramble, I had great fun with the animation module.  SwiftUI is pretty amazing at generating some truly attractive effects with very little code and Paul Hudson does a great job highlighting that strength.

(LU6)

Monday, November 11, 2024

Going Strong and Then I Hit a Bump

So I was actually ahead of my self-imposed schedule.  I was really happy with my results and wanted to fix a few things and add a feature or two.  Then I hit a snag on 100 Days of SwiftUI, Project 5.  I'll go briefly into it here, but follow the link below for the full explanation and hopefully some helpful insights from others.

In an effort to add more visual clues when entering words for Project 5, WordScramble, I tried to change the color of the text in the TextField if the word being typed changed from invalid to valid and vice-versa.  The TextField ignored all efforts to make any style change to the text.  I could make changes to the appearance of the TextField but not to the text using such modifiers as .foregroundStyle(), .fontWeight(), and others.

https://www.hackingwithswift.com/forums/100-days-of-swiftui/unusual-behavior-when-trying-to-change-the-style-of-the-text-in-a-swiftui-textfield/28414

From here, I'm going to add a workaround for the above problem in WordScramble, add a feature to decide whether to keep the word successfully entered or to clear it, remove all the debugging code, file a bug with Apple, and move on!

Still no word from my programming study partner.

(LU5)

Thursday, November 7, 2024

A Productive Few Days Despite Current Events

So, a great amount has happened over the past four day.  I studied a great many 100 Days of SwiftUI lessons and I'm back on track. I worked with my study partner on Sunday and Monday (more on that below).  I did a whole bunch of testing for a new app from Paul Hudson, which he will release soon. Thank you for the opportunity, Paul.  And experienced a disastrous election cycle (from my perspective).

On the SwiftUI front, I have completed everything through Day 25.  I made some great updates and UI fixes to my projects, especially GuessThatFlag.  I am now working on Day 26 and hoping to complete Day 28 before bedtime.

Here are some screenshots from GuessTheFlag:

My study partner has gone silent again.  I wanted to hear about his coding interview yesterday, but there are a great many things that could be impacting him (the election, the interview, family issues), so I'm leaving him alone until he is ready to reach out.

(LU4)

Sunday, November 3, 2024

Big Push

So I reached out to my accountability partner last night.  And they reached back.  Excellent.  It would be so much worse if I had just gotten silence. 

So, as I kind of thought, they were struggling with their situation of having been laid off from their job.  There are a lot of feelings of anger and probably self-doubt.  It is good to sort through all that before rushing into finding another job.  Remember, getting laid-off says much more about the company's situation than it does about you, your abilities, and your worth.

Anyway, my partner is ready to get to work, and begin learning SwiftUI starting today.  Unfortunately, he is much more focused on a coding exam he has coming up on Wednesday than working on the fundamentals of SwiftUI.  So, I convinced him to get started on SwiftUI and I would find him a tutorial to work on in a day or so to prepare him for the programming test he thinks is coming.  It is a start.  

For me, I continue to push forward, accelerating the pace from the past week, as it is a weekend with no external commitments.   Also, I'm hoping my partner will inspire me, which should also increase my pace.

 (LU3)

Friday, November 1, 2024

One Week Into Leveling Up

 So, my accountability partner and I started 100 Days of SwiftUI a week ago.  My goal was three "days" per day.  That has not been the case.  I am averaging two per day and actually a hair less than that.  I have just completed my seventh day, and I have completed 13 days of SwiftUI.  So, how is my accountability partner doing?  I don't know.  They have gone silent.  After I post this, I will check in with them again and see if I get a response.

(LU2)

Friday, October 25, 2024

Starting to Level Up Again

 Okay, we are making that climb up the mountain again.  Every few years, after falling behind on the latest advancements in all things Apple Developer, I make a concerted effort to fill in the gaps that have been created during that timeframe.  I am told the best way to hold myself accountable for sustained superior performance in this area is to find a "study" partner or to post about my journey on social media.  Given my partner has proven even less reliable than me, I am resorting to posting.  I will start here on Blogger, but may finally dust off my microblog account if it still exists or start posting to Mastodon (rather than just following).  I will definitely NOT be posting to X (nee twitter).  Wish me luck!

(LU1)