JSON配列から字幕を取得して、MKAnnotationに字幕を追加しようとしています。タイトルを取得し、以下のようにView Controllerと調整することはできますが、JSONキー「cityName」から字幕を取得するために何をすべきかわかりません。どんな助けでも素晴らしいでしょう!ありがとうございました!
MapViewController.m
location.latitude = [dictionary[@"placeLatitude"] doubleValue];
location.longitude = [dictionary[@"placeLongitude"] doubleValue];
newAnnotation = [[MapViewAnnotation alloc] initWithTitle:dictionary[@"placeName"]
andCoordinate:location];
MapViewAnnotation.h
@interface MapViewAnnotation : NSObject <MKAnnotation> {
NSString *title;
CLLocationCoordinate2D coordinate;
}
@property (nonatomic, copy) NSString *title;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *subtitle;
- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d;
@end
MapViewAnnotation.m
#import "MapViewAnnotation.h"
@implementation MapViewAnnotation
@synthesize title, coordinate, subtitle;
- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d {
title = ttl;
coordinate = c2d;
subtitle = [SUBTITLE PULLED FROM JSON]
return self;
}
@end