Bug 25393 - MKPointAnnotation.Coordinate read-only
Summary: MKPointAnnotation.Coordinate read-only
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Pre-release ()
Version: XI 8.6.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-12-15 11:42 UTC by Stéphane Di Prizio
Modified: 2015-03-01 13:06 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Stéphane Di Prizio 2014-12-15 11:42:53 UTC
Xamarin.iOS Version: 8.6.0.22 (Business Edition)
Xamarin Studio 5.7

var annotation = new MKPointAnnotation {Coordinate = coords};

should compile (and does compile on earliers Xamarin.iOS builds.
in X.iOS 8.6.0.22 throw a compiler error :
Error CS0200: Property or indexer `MapKit.MKShape.Coordinate' cannot be assigned to (it is read-only) (CS0200)

In Apple documentation, Coordinate belongs to MKPointAnnotation and not MKShape, and should be read write.
Comment 1 Sebastien Pouliot 2014-12-15 17:27:04 UTC
Yes, MKPointAnnotation is missing the property. I'll look at fixing it. This was changed in unified because of the way we're now exposing (more accurately) the ObjC protocols in the API.


As to why it's in MKShape it's because MKShape [1] conforms to the MKAnnotation protocol [2], where the getter is _required_ but the setter is optional.

This is why you can get the `Coordinate` (as a property) but need to call `SetCoordinate` method.

Because this protocol exists you can do:

    var annotation = new MKPointAnnotation ();
    annotation.SetCoordinate (coords);

to get around the missing setter in MKPointAnnotation.

[1] https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKShape_class/index.html#//apple_ref/occ/cl/MKShape

[2] https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKAnnotation_Protocol/index.html#//apple_ref/occ/intf/MKAnnotation
Comment 2 Sebastien Pouliot 2014-12-16 14:42:31 UTC
Fixed in master / de702560af6f055e21d93625060264d6c4d807f5
Comment 3 edgeric 2015-03-01 13:06:49 UTC
When is this fix going out?