0
我是新来的核心数据..如何删除核心数据中的条目
我知道如何存储和项目。
- (void)dbSave:(NSString *)uri withContent:(NSDictionary *)content withExpiry:(double)date {
Cache *cache = [self dbLoad:uri];
if (cache == nil) {
cache = [NSEntityDescription insertNewObjectForEntityForName:@"Cache" inManagedObjectContext:[self managedObjectContext]];
}
double time = (double) [[NSDate date] timeIntervalSince1970] + date;
[cache setLocal:uri];
[cache setTime:@(time)];
NSMutableData *data = [[NSMutableData alloc] init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
[archiver encodeObject:content forKey:@"data"];
[archiver finishEncoding];
[cache setData:data];
NSError *error;
if (![[self managedObjectContext] save:&error]) {
}
}
但我坚持建立以清除这一核心数据的数据库的方法..有谁知道怎么样?
您是否要求删除所有表?放一张桌子?或从表中删除一个字段? – Brandon
查看此链接http://stackoverflow.com/questions/1077810/delete-reset-all-entries-in-core-data –
[从Core-Data中删除特定项/行](http:// stackoverflow.com/questions/6524876/removing-a-specific-entry-row-from-core-data) – shallowThought