#import <Foundation/Foundation.h>
@interface Location : NSObject
{
int x_;
int y_;
}
@property(assign) int x;
@property(assign) int y;
@end
#import "Location.h"
@implementation Location
@synthesize x = x_;
@synthesize y = y_;
@end
-(id) calcKey:(int)x theY:(int)y{
Location* loc = [[Location alloc]init];
loc.x = x;
loc.y = y;
return loc;
}
for(id innerObj in arr){
NSMutableDictionary* dic = [NSMutableDictionary dictionary];
for(id innerObj in arr){
MyStorage* storage = (MyStorage*)innerObj;
id key = [self calcKey:storage.x theY:storage.y];
[dic setObject:bri forKey:key];
}
}
嗨,我正在尝试将存储添加到 NSMutableDictionary,我的目的是使用此字典 dic 来加速进一步搜索位置 (x,y) 具有存储的位置。但它总是失败......带有以下警告,任何人都可以帮助我 ?非常感谢!:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Location copyWithZone:]: unrecognized selector sent to instance 0x6b4b160'