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

Day 73: Conceptual doubts

Forums > 100 Days of SwiftUI


I just completed the challenges for Project 14. There are a couple of things I noticed while doing these tasks and I'm hoping someone here would have an explanation for it.

  1. In ContentView-ViewModel.swift we import CoreLocation to work with CLLocationCoordinate2D. Why wasn't CoreLocation imported in Location.swift?
  2. In Part 3 of the project (Selecting and editing map annotations), we change the id property of the Location struct to a variable, so as to assign to a new id while updating the location. Paul provides an explanation for it in the video. However, I changed it back to a constant property and the location gets updated just fine. Has anyone else noticed this?

I'm using Xcode 15.2 and deploying for iOS 17.0.1.


The struct also contains a computed variable of type CLLocationCoordinate2D.

struct Location: Codable, Equatable, Identifiable {
    var id: UUID
    var name: String
    var description: String
    var latitude: Double
    var longitude: Double

    var coordinate: CLLocationCoordinate2D {
        CLLocationCoordinate2D(latitude: latitude, longitude: longitude)


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!

Reply to this topic…

You need to create an account or log in to reply.

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.