According to your comment, the code you tried is something like this:
view.annotation.subtitle = @"something";
The compiler will give the error "Assignment to readonly property" here because the annotation
property of MKAnnotationView
is typed as the generic id <MKAnnotation>
.
The MKAnnotation
protocol defines subtitle
as readonly as the default.
The MKPointAnnotation
class (which you are using for your annotations according to another comment) implements MKAnnotation
but overrides subtitle
as write-able.
To avoid the compiler error, you need to cast view.annotation
to MKPointAnnotation
(which in your case it really is). For example:
if ([view.annotation isKindOfClass:[MKPointAnnotation class]])
{
MKPointAnnotation *pa = (MKPointAnnotation *)view.annotation;
pa.subtitle = @"something";
}