where are my parents in swift

Determining the location of your parents can be done by using the CoreLocation and MapKit frameworks in Swift.

Here's a basic example of how you can get the current location of the user and display it on a map. You can use this as a starting point and customize it to fit your needs.

import UIKit
import MapKit
import CoreLocation

class ViewController: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate {

    @IBOutlet weak var mapView: MKMapView!
    let locationManager = CLLocationManager()

    override func viewDidLoad() {
        // Ask for location permission
        locationManager.delegate = self
        locationManager.desiredAccuracy = kCLLocationAccuracyBest

        // Set up map view
        mapView.delegate = self
        mapView.showsUserLocation = true

    // MARK: CLLocationManagerDelegate methods

    func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
        if status == .authorizedWhenInUse {

    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        guard let userLocation = locations.last else { return }
        let region = MKCoordinateRegion(center: userLocation.coordinate, latitudinalMeters: 1000, longitudinalMeters: 1000)
        mapView.setRegion(region, animated: true)
1264 chars
37 lines

This code sets up a CLLocationManager to get the user's current location and a MKMapView to display it on a map. It also asks the user for permission to use their location, and centers the map on their location once it's obtained.

To find the location of your parents, you would need to get their location data and then display it on the map as well. There are several ways to do this, depending on your specific use case. You could have your parents manually enter their location, or you could use a service like iCloud or a third-party location sharing app to obtain their location data. Once you have their location, you can add a pin to the map to display it.

gistlibby LogSnag