🍎 Swift & iOS Intermediate

What is Core Location in iOS?

Why Interviewers Ask This

This question targets practical, hands-on experience with Swift & iOS. Interviewers want to see if you've worked with these concepts in real projects, not just read about them. Strong answers include concrete examples.

Answer

Core Location provides device location and heading information — GPS, Wi-Fi positioning, cell towers, and iBeacon. Usage requires explicit user permission. Setup: add to Info.plist: NSLocationWhenInUseUsageDescription — explains why you need location. Implementation: import CoreLocation class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate { private let manager = CLLocationManager() @Published var userLocation: CLLocation? @Published var authorizationStatus: CLAuthorizationStatus override init() { super.init() manager.delegate = self manager.desiredAccuracy = kCLLocationAccuracyBest } func requestPermission() { manager.requestWhenInUseAuthorization() } func startUpdating() { manager.startUpdatingLocation() } func stopUpdating() { manager.stopUpdatingLocation() } // Delegate: func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { userLocation = locations.last } func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { authorizationStatus = manager.authorizationStatus switch manager.authorizationStatus { case .authorizedWhenInUse, .authorizedAlways: startUpdating() case .denied, .restricted: print("Location access denied") default: break } } func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { print("Location error: \(error)") } }. Authorization levels: .authorizedWhenInUse (in foreground), .authorizedAlways (foreground + background — justify to App Review), .denied, .restricted, .notDetermined. One-time location: manager.requestLocation() — single update, simpler for one-off needs. Region monitoring: get notified when device enters/exits a circular region (geofencing).

Pro Tip

If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.