BLACK FRIDAY: Save 50% on all my Swift books and bundles! >>

Day 73: Conceptual doubts

Forums > 100 Days of SwiftUI

Hello,

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.

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)
    }
}

1      

Save 50% in my WWDC sale.

SAVE 50% All our books and bundles are half price for Black Friday, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

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.