I'm trying to make an if let statement with the following:
if let p = CLPlacemark(placemark: placemarks?[0]) {
Currently it's telling me "Value of optional type 'CLPlacemark?' not unwrapped" and instructing me to put
(placemark: (placemarks?[0])!) {
However if I do that, it then tells me "Initializer for conditional binding must have optional type, not 'CLPlacemark'"
I honestly have no idea how to fix this and could use any help. Thanks in advance
Try this
if let validPlacemark = placemarks?[0]{
let placemark = validPlacemark as? CLPlacemark;
}
You need the ? because placemarks is not guaranteed to have a value