我目前正在实施一个自定义 IASKSettingsStore 以使用核心数据。你可以看到下面的代码。问题是值的存储变得非常缓慢。例如,当我在文本字段中输入内容时,我知道 IASKAppSettingsViewController 会存储所有更改,但我发现即使是单个更改也存储得非常慢。我怎样才能使这项工作更快?
我监督什么?提前致谢。
到目前为止,自定义 IASKSettingsStore 如下所示:
@implementation GPSettingsStoreCoreData
@synthesize managedObject = _managedObject;
- (id)initWithManagedObject:(NSManagedObject *)managedObject {
self = [super init];
if( self ) {
_managedObject = managedObject;
}
return self;
}
- (id)init
{
if (self = [super init]) {
_managedObject = nil;
}
return self;
}
- (void)setBool:(BOOL)value forKey:(NSString*)key {
[self.managedObject setValue:[NSNumber numberWithBool:value] forKey:key];
}
- (void)setFloat:(float)value forKey:(NSString*)key {
[self.managedObject setValue:[NSNumber numberWithFloat:value] forKey:key];
}
- (void)setDouble:(double)value forKey:(NSString*)key {
[self.managedObject setValue:[NSNumber numberWithDouble:value] forKey:key];
}
- (void)setInteger:(int)value forKey:(NSString*)key {
[self.managedObject setValue:[NSNumber numberWithInt:value] forKey:key];
}
- (void)setObject:(id)value forKey:(NSString*)key {
[self.managedObject setValue:value forKey:key];
}
- (BOOL)boolForKey:(NSString*)key {
return [[self.managedObject valueForKey:key] boolValue];
}
- (float)floatForKey:(NSString*)key {
return [[self.managedObject valueForKey:key] floatValue];
}
- (double)doubleForKey:(NSString*)key {
return [[self.managedObject valueForKey:key] doubleValue];
}
- (int)integerForKey:(NSString*)key {
return [[self.managedObject valueForKey:key] intValue];
}
- (id)objectForKey:(NSString*)key {
return [self.managedObject valueForKey:key];
}
@end