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

Could I please ask for a quick code review?

Forums > 100 Days of SwiftUI

Hello, I am following the 100 days course. Due to health reasons, I had to take two weeks off which made me very sad and anxious about my progress, as I don't know whether I remember everything well. But I have taken on the challenge after project 9 and I would like to ask you how is this code? Is there anything terribly bad in it? I know my UI isn't stylish, but that's because I am blind. Also, I often forget the specific function names and so I look into my old project. Is this a bad thing? https://github.com/Nuno69/MaoTrack

2      

Stylisticlly, it's clean. My only recommendation is adding a Spacer between the name and noCompleted texts in your ActivityIntroView.

In terms of code grouping I really liked your ActivityIntroView. It's so much cleaner than what I usually do!

When you want to update an activity's noCompleted variable, it is possible to do an in place exchange. Instead of:

if let index = activities.activities.firstIndex(where: {$0.id == tempActivity.id}) {
                    activities.activities.remove(at: index)
                    activities.activities.append(tempActivity)
                }

you can write:

if let index = activities.activities.firstIndex(where: {$0.id == tempActivity.id}) {
                    activities.activities[index] = tempActivity
                }

This only preserves the order of the array, neither is better. It is an alternative.

Not remembering exactly what something is called is super common. Learning the naming conventions helps, but a lot of learning this stuff is just learning where to find the information next time you need to look it up.

I hope you continue to feel better.

2      

Thank you for your help. I have added the spacer and I hope it will be much better now.

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.