MapKit app - best way to store thousands of annotations?

Hi,

Question:

I will have thousands of MapKit annotations -- what is the best way to store these and save user changes to each annotations? The user will only be able to change a single Bool for each annotation, everything else (coordinate, title etc) will not change.

Background:

I'm playing around with my beginner project. It's a MapKit-based app where the purpose is to show a number of annotations on a map. Some of these annotations/locations may be added to a list of favorites, which should be displayed in a separate TableViewController.

I've stored some dummy annotations in an array:

Code Block
    let places = [
        Location(name: "Mordor", latitude: -41.29, longitude: 175, isFavorite: false, website: "http://www.mordor.com"),
        Location(name: "Lorien", latitude: -41.31, longitude: 174, isFavorite: false, website: "http://www.lorien.com"),
            ]

Then placed those annotations on the map:

Code Block
  fileprivate func addLocationToMap() {
        for place in places {
            let annotation = MKPointAnnotation()
            annotation.coordinate = CLLocationCoordinate2D(latitude: place.latitude, longitude: place.longitude)
            annotation.title = place.name
            annotation.subtitle = place.website
            mapView.addAnnotation(annotation)
        }
    }

Clicking on the annotation displays a callout, and clicking on the rightCalloutAccessoryView opens a SFSafariViewController displaying the website from the array.

Now, this all works -- with a handful of dummy locations in my places array. But I will need hundreds, possibly thousands of locations, and I wonder if having my for loop go through an array with thousands of annotations is not the most efficient way of doing it. I could be wrong.

What's the best way to store these locations -- should I make one enormous array manually (tedious, but at least I know how to do it), or should I look into a database of some kind (I know nothing about databases, but will try to learn if needed).

I also have an isFavorite Bool in the array -- the idea is that the user can tap the leftCalloutAccessoryView (which is a UIImageView(image: UIImage(systemName: "heart"))), turn the isFavorite Bool to true and change the UIImage to "heart.fill",.

Then a separate TableViewController will display all locations for which isFavorite == true. So the way I store the locations must let the user flip the isFavorite Bool and store that value on the device.

I'm learning by doing (and Googling), grateful for any tips.
MapKit app - best way to store thousands of annotations?
 
 
Q