小编Rya*_*yan的帖子

将数据存储在MKAnnotation中?

所以我对Xcode和Objective-C很陌生.我有几个ArtPiece对象,各种属性存储在一个数组中.然后我将它们作为MKAnnotations添加到mapview.我需要做的是在点击时发送它们来自的阵列位置的引用.我相信MKAnnotations只有数据成员标题,图像和位置,因此当我从对象创建MKAnnotation时,注释不会保留任何其他属性.所以,我的问题是,我如何设法保持对创建注释的对象的数组位置的引用,以便我可以将其发送到其他方法,以便他们可以从数组中检索有关该对象的其他信息以获取详细信息views等有没有办法在注释中存储单个int值?我不认为还有其他想法吗?

这是我的ArtPiece.h:

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface ArtPiece : NSObject <MKAnnotation>{

    NSString *title;
    NSString *artist;
    NSString *series;
    NSString *description;
    NSString *location;
    NSString *area;
    NSNumber *latitude;
    NSNumber *longitude;
    UIImage *image;
}

@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *artist;
@property (nonatomic, retain) NSString *series;
@property (nonatomic, retain) NSString *description;
@property (nonatomic, retain) NSString *location;
@property (nonatomic, retain) NSString *area;
@property (nonatomic, retain) NSNumber *latitude;
@property (nonatomic, retain) NSNumber *longitude;
@property (nonatomic, retain) UIImage *image;


@end
Run Code Online (Sandbox Code Playgroud)

这是.m:

#import "ArtPiece.h"
#import …
Run Code Online (Sandbox Code Playgroud)

arrays xcode objective-c mkmapview mkannotation

15
推荐指数
1
解决办法
5937
查看次数

从Xcode中的存储库中删除未引用的图像

我从我的资源文件夹中删除了default.png,因为我想要一个不同的图像用于加载屏幕,但我刚刚删除了一个显然是愚蠢的事情的引用.我将新图像拖动到资源并尝试将名称更改为Default.png,但它不会让我,我认为是因为第一个Default.png仍在某个存储库中.无论如何,当在xcode中不再可见时,如何从存储库中删除该图像(以及我可能已经完成相同操作的其他图像)?

terminal xcode repository

3
推荐指数
1
解决办法
8842
查看次数