Why not [[userLocation location]coordinate]


#1
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    CLLocationCoordinate2D loc = [userLocation coordinate];
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, 25000, 25000);
    [worldView setRegion:region animated:YES];
}

userlocation is an instance of MKUserlocation,
coordinate is a method of CLLocation,
so,why not
CLLocationCoordinate2D loc = [[userLocation location]coordinate],
i tried this,it works fine too.
i’m confused,please help.


#2

Are you confused because MKUserLocation class does not have the coordinate method listed in its class reference?

It does actually have the coordinate method because MKUserLocation conforms to MKAnnotation protocol which specifies the method.


#3

[quote=“ibex10”]Are you confused because MKUserLocation class does not have the coordinate method listed in its class reference?

It does actually have the coordinate method because MKUserLocation conforms to MKAnnotation protocol which specifies the method.[/quote]
understand.3Q