The "coordinate" property of MKAnnotation Protocol
My question is about the "readonly" attribute of the "coordinate" property. In the Protocol there is also a "setCoordinate" instant method listed. It says in the documentation that it is meant to support "dragging".
My question is :
1
If the coordinate can be set, then why there is a "readonly" attribute assigned to it开发者_JAVA技巧 ?
2
I am thinking of using a single temporary MKAnnotation object to populate an array. The scheme is to assign different coordinate values and add it to the array repeatedly. But the scheme would not work if the coordinate property is "readonly". Or can I use the "setCoordinate" for this purpose anyway ?
Am just wish to avoid having to create multiple MKAnnotation objects to populate the array (since the array can potentially be more that just a few points).
Hope that somebody knowledgable in this area could help ...
http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKAnnotation_Protocol/Reference/Reference.html
The setCoordinate:
method is optional. If your annotation supports dragging, you can implement it but you don't have to. The readonly property on the other hand is mandatory.
I am thinking of using a single temporary MKAnnotation object to populate an array. The scheme is to assign different coordinate values and add it to the array repeatedly. But the scheme would not work if the coordinate property is "readonly". Or can I use the "setCoordinate" for this purpose anyway ?
This scheme won't work in any case. If you add the annotation to your array, then modify the coordinate and add it again, you'll have the exact same annotation twice in your array, with the same coordinates. If you want an array of annotations with different coordinates, you will need to create a distinct annotation object for each coordinate.
精彩评论