Ajoutez un fichier Swift, nommez-le ListeViewController.swift.
Écrivez le code suivant pour ajouter la classe ListeViewController :
import UIKit import CoreLocation class ListeViewController: UITableViewController { let locationManager = CLLocationManager() var localisationUtilisateur: CLLocation? = nil // MARK: Cycle de vie override func viewDidLoad() { locationManager.desiredAccuracy = kCLLocationAccuracyKilometer locationManager.distanceFilter = 100 locationManager.delegate = self } override func viewWillAppear(_ animated: Bool) { utiliserLocalisationSiValide(locationManager.location) tableView.reloadData() locationManager.startUpdatingLocation() } override func viewWillDisappear(_ animated: Bool) { locationManager.stopUpdatingLocation() } // MARK: Utilisation de la position func utiliserLocalisationSiValide(_ localisation: CLLocation?) { guard let localisation = localisation else { localisationUtilisateur = nil return ...
Abonnement
tous les livres et vidéos ENI en illimité sans engagement
du livre imprimé ou du livre numérique