Alright. I can understand that those are necessary so I have included them into my info.plist file, yet I'm still getting quite a lot of errors. Mostly the the Expected Declaration error. I've been editing it a lot and moving things around as well as putting more things in that I've researched, and that you all have reccomended. So now it doesn't appear much like what I had before. And in Info.plist, I have 'Privacy - Location When In Use Usage Descriptio'n, as well as 'Privacy - Location Always Usage Description'.
(Though my value for the 'Always Usage' is a just a String which is a reminder to myself that I shouldn't use this one because Apple reccomends against it)
My first question is, how can I make something happen when two things are true, and one of those things being proximity to a designated locaion? My hope was Boolean1 and Boolean2, and only when they are both true a Boolean3 is made true.
Can you see an error in this?
//
// Copyright © 2018 Rob. All rights reserved
//
import UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
var locationManager:CLLocationManager!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
determineMyCurrentLocation()
}
func determineMyCurrentLocation() {
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
if CLLocationManager.locationServicesEnabled() {
locationManager.startUpdatingLocation()
// locationManager.startUpdatingHeading()
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let userLocation:CLLocation = locations[0] as CLLocation
// Call stopUpdatingLocation() to stop listening for location updates,
// other wise this function will be called every time when user location changes.
// manager.stopUpdatingLocation()
print("user latitude = \(userLocation.coordinate.latitude)")
print("user longitude = \(userLocation.coordinate.longitude)")
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error)
{
print("Error \(error)")
}
}
Maybe I need to back WAY up and start learning again...but where can I start? If you have a reccomendation on how or where I should start taking a "class" for Xcode, let me know.