我想利用安全感来收集一些数据,然后使用。 我的习俗目标如下:
@interface MyData : NSObject {
NSRange range;
NSMutableArray *values;
}
@property (nonatomic, retain) NSMutableArray *values;
执行:
- (id)init {
if (self = [super init]) {
values = [[NSMutableArray alloc] init];
}
return self;
}
以及当一anna大麻ache时,如使用:
NSMutableDictionary *cache = [[NSMutableDictionary alloc] init];
NSString *key = @"KEY";
MyData *data = [[MyData alloc] init];
// save some data into data
[data.values addObject:"DATA1"];
[data.values addObject:"DATA2"];
//... ...
[cache setObject:data forKey:key];
我的问题是切记。 数值为零,但后来又取回该物体如下:
[cache objectForKey:@"KEY"];
i can retrieve "data" and the object s memory address is the same as the address when i put it into cache. what s wrong? i need some kind guys help, any info is helpful. thanks