MKTeleportingUserLocation doesn't conform to MKAnnotation protocol
| Originator: | futuretap | ||
| Number: | rdar://13284914 | Date Originated: | 25-Feb-2013 05:13 PM |
| Status: | Open | Resolved: | |
| Product: | iPhone SDK | Product Version: | 6.1.2 |
| Classification: | Crash | Reproducible: | Unable |
In my MKMapViewDelegate my -mapView:didSelectAnnotationView: was called with an MKTeleportingUserLocation object as view.annotation.
I queried annotationView.annotation.subtitle and it crashed with this exception:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MKTeleportingUserLocation subtitle]: unrecognized selector sent to instance 0x1d53cf60'
I believe I'm doing nothing wrong here and it shouldn't crash. Don't know under which circumstances an MKTeleportingUserLocation annotation is used but according to the contract, annotationView.annotation should conform to the MKAnnotation protocol:
@property (nonatomic, retain) id <MKAnnotation> annotation
which defines
@property (nonatomic, readonly, copy) NSString *subtitle
28-Feb-2013 05:14 PM Apple Developer Bug Reporting Team :
Engineering has determined that this issue behaves as intended based on the following information:
It appears you are missing a crucial part of MKAnnotation.h. Specifically:
@optional
....
@property (nonatomic, readonly, copy) NSString *subtitle;
It is not safe to call -title or -subtitle on something just because you know it conforms to <MKAnnotation>. MKTeleportingUserLocation definitely does conform to <MKAnnotation>.
28-Feb-2013 06:08 PM Ortwin Gentz:
Thanks, makes sense.
I didn't check the header file, only the documentation. In the latter, there's no clear indication that some of the properties are @optional. You might want to clarify in the documentation.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!