Say I have a instance of a class let geocoder = CLGeocoder().
I can now call geocodeAddressString, a method of the CLGeocoder class:
geocoder.geocodeAddressString(myObject["Location"] as! String, completionHandler: {
(placemarks, error) -> Void in
...
}
Though, why can't I directly do the following?
// I haven't instantiated the `CLGeocoder` class this time
CLGeocoder.geocoder.geocodeAddressString(myObject["Location"] as! String, completionHandler: { (placemarks, error) -> Void in
...
})
For example, I can do:
// I don't instantiate the UIView class here
UIView.animateWithDuration(0.4, animations: {
() in
...
}
When do I have to instantiate a class and when I shouldn't?