For some strange reason it will crash the first time I try to run the program but if I run it again while the simulator is still running it works fine. Here is a snippit of code that is giving the issue.
class CityList : NSObject, CLLocationManagerDelegate {
// stored properties
var cities: [City]
var currentLocation: CLLocation? = nil
static let sharedInstance = CityList()
static let firstNotif = Notification.Name(rawValue: "test")
static let secondNotif = Notification.Name(rawValue: "test2")
let locationManager = CLLocationManager()
// initializers
override init () {
cities = [
City(name: "Medford", state: "Oregon", latitude: 42.3266667, longitude: -122.8744444),
City(name: "Seattle", state: "Washington", latitude: 47.6063889, longitude: -122.3308333),
City(name: "Grants, Pass", state: "Oregon", latitude: 42.4391667, longitude: -123.3272222),
City(name: "Applegate", state: "Oregon", latitude: 42.2570662, longitude: -123.1683833),
City(name: "San Francisco", state: "California", latitude: 37.775, longitude: -122.4183333)
]
super.init()
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()// request user authorization
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
currentLocation = locationManager.location
cities.append(City(name: "test", state: "test", location: currentLocation!))
}