gpt4 book ai didi

iphone - 从 JSON 数组中提取 MKAnnotation 字幕

转载 作者:行者123 更新时间:2023-11-28 22:39:55 24 4
gpt4 key购买 nike

我正在尝试通过从 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

最佳答案

这里有什么问题?只需完全按照您对 title 属性的操作即可。

关于iphone - 从 JSON 数组中提取 MKAnnotation 字幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14827932/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com