I am working on a piece of code using CoreLocation
and CLBeaconRegion
, but I'm receiving an error:
fatal error: unexpectedly found nil while unwrapping an Optional value
I want to create a region variable holding a CLBeaconRegion
like so:
let region = CLBeaconRegion(proximityUUID: NSUUID(UUIDString: "AM_2015-06-10")!, identifier: "AnyMorning")
A bit later in my code, I am calling:
locationManager.startRangingBeaconsInRegion(region)
And when I launch the app, I receive the above error. What is the right way to solve this?
"AM_2015-06-10"
is not a valid UUIDString! soNSUUID(UUIDString: "AM_2015-06-10")!
will crash your application