每次我的应用程序运行时,它都会生成存储在核心数据实体“实体”中的数据。我的获取请求的结果不会使用此最新数据进行更新,除非我退出应用并再次重新启动它。我认为“shouldRefreshRefetchedObjects”属性可以解决这个问题,但显然不是。我当前的获取请求代码如下:
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Entity" inManagedObjectContext:context];
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"date_time" ascending:YES];
NSArray *Descriptors = [NSArray arrayWithObject: descriptor];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setShouldRefreshRefetchedObjects:YES];
[fetchRequest setEntity:entity];
[fetchRequest setSortDescriptors:Descriptors];
NSArray *historyDataArray = [context executeFetchRequest:fetchRequest error:Nil];