I am new to swift and I want to know if there is a difference between geoCoder() :
var geoCoder:CLGeocoder = CLGeocoder()
geoCoder().reverseGeocodeLocation(newCoordinate, completionHandler: { (<#[CLPlacemark]?#>, <#NSError?#>) -> Void in
<#code#>
})
and geroCoder:
var geoCoder:CLGeocoder = CLGeocoder()
geoCoder.reverseGeocodeLocation(newCoordinate, completionHandler: { (<#[CLPlacemark]?#>, <#NSError?#>) -> Void in
<#code#>
})
Thanks in advance
Yes, there's a difference. The first one won't compile (even if you fill in the placeholders correctly), and the second will.
You can't say geoCoder()
because geoCoder
is not a function.
(In C++, we can overload the ()
operator to make things that are not functions act like functions. Swift doesn't allow that, so you can only put ()
after things that are genuinely functions.)