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      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

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.