gpt4 book ai didi

ios - 使用 map 上的 PINS 时,由于未捕获的异常 'NSInvalidArgumentException' 而终止应用程序

转载 作者:行者123 更新时间:2023-11-28 23:09:38 24 4
gpt4 key购买 nike

当我运行我的应用程序时,它崩溃了并且出现了这个错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AnnotationsDisplay coordinate]: unrecognized selector sent to instance 0x795bda0'

AnnotationsDisplay 这是一个管理在 map 上显示 PINS 的类。

编辑:这是我的 AnnotationsDisplay 类代码:

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface AnnotationsDisplay : NSObject<MKAnnotation> {
NSString *title;
CLLocationCoordinate2D coordinate;
}
- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d;
@end

.m:

#import "AnnotationsDisplay.h"

@implementation AnnotationsDisplay
- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d {
title = ttl;
coordinate = c2d;
return self;
}
@end

最佳答案

@protocol MKAnnotation <NSObject>

// Center latitude and longitude of the annotion view.
// The implementation of this property must be KVO compliant.
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;

@optional

// Title and subtitle for use by selection UI.
@property (nonatomic, readonly, copy) NSString *title;
@property (nonatomic, readonly, copy) NSString *subtitle;

// Called as a result of dragging an annotation view.
- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate NS_AVAILABLE(NA, 4_0);

@end

属性已经在 MKAnnotation 协议(protocol)中声明。只需为每个属性添加 @synthesize。

关于ios - 使用 map 上的 PINS 时,由于未捕获的异常 'NSInvalidArgumentException' 而终止应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8616672/

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