Search code examples
iosiphoneswiftswift2mkmapitem

MKMapItem error in swift 2.0


When I run the following code, I get the error "Cannot call value of non function type 'MKMapItem?'

request.source(MKMapItem.mapItemForCurrentLocation())

It worked fine in swift 1.2 what has changed ?


Solution

  • In Swift 2 (Xcode Beta 5), source is now a property of MKDirectionsRequest:

    Hence, instead of:

    request.source(MKMapItem.mapItemForCurrentLocation())
    

    It is now:

    request.source = MKMapItem.mapItemForCurrentLocation()