所以,我的情况是这样的:
我的iOS应用程序中有一个NSManagedObject子类,作为一个属性,我想存储MKPolygon对象的内容.我决定解决这个问题的方式(以及它是否有效可能是一个不同的问题)是将polygon属性声明为可转换对象,然后存储包含多边形点的NSArray(作为NSValue对象).
为此,我在模型对象上编写了几个便捷类方法:
+ (NSArray *)coordsArrayFromMKPolygon:(MKPolygon *)polygon pointCount:(int)count
{
CLLocationCoordinate2D *coords = (CLLocationCoordinate2D *)malloc(sizeof(CLLocationCoordinate2D) * count);
[polygon getCoordinates:coords range:NSMakeRange(0, count)];
NSMutableArray *coordsArray = [NSMutableArray array];
for (int i = 0; i < count; i++) {
NSValue *coordVal = [NSValue valueWithBytes:&coords[i] objCType:@encode(CLLocationCoordinate2D)];
[coordsArray addObject:coordVal];
}
free(coords);
return [NSArray arrayWithArray:coordsArray];
}
+ (MKPolygon *)polygonFromCoordsArray:(NSArray *)coordsArray pointCount:(int)count
{
CLLocationCoordinate2D *coords = (CLLocationCoordinate2D *)malloc(sizeof(CLLocationCoordinate2D) * count);
for (int i = 0; i < count; i++) {
CLLocationCoordinate2D coord;
[[coordsArray objectAtIndex:i] getValue:&coord];
coords[i] = coord; …Run Code Online (Sandbox Code Playgroud) 在昨晚更新到适用于iOS6的最新版Xcode 4.5之后,我得到了类似的警告和错误
属性'mapAnnotation'需要定义方法'mapAnnotation' - 使用@synthesize,@ dynamic或在此类实现中提供方法实现
因为缺少@synthesize语句,甚至是关于未知iVars的错误,如果我使用它们.
问题是,我认为没有必要写这些@synthesize语句自从Mountain Lion发布的最后一个Xcode Update 4.5以来,并且在我昨晚更新Xcode之前我的所有项目都没有它们(我删除了)从我的文件回来的一大堆@synthesize语句然后它甚至还在Release-Notes中:
•使用属性时,默认情况下会生成Objective-C @synthesize命令.
所以我很困惑,我错过了一个新的项目设置,它会自动生成@synthesize一代吗?
但是,当我创建一个新项目并尝试它时,它甚至都无法工作