ios - IOS核心数据。是否可以在不获取数据的情况下查看已保存的数据

标签 ios objective-c core-data

我正在研究核心数据库项目。我想知道是否可以在不获取数据的情况下查看哪些数据保存在coredata中?

例如:

我正在使用本教程来学习核心数据。 **

Core Data demo from AppCoda

我实现了以下方法来将数据保存在数据模型中。(coredata)

- (IBAction)save:(id)sender {
NSManagedObjectContext *context = [self managedObjectContext];

// Create a new managed object
NSManagedObject *newDevice = [NSEntityDescription insertNewObjectForEntityForName:@"Device" inManagedObjectContext:context];
[newDevice setValue:self.nameTextField.text forKey:@"name"];
[newDevice setValue:self.versionTextField.text forKey:@"version"];
[newDevice setValue:self.companyTextField.text forKey:@"company"];

NSError *error = nil;
// Save the object to persistent store
if (![context save:&error]) {
    NSLog(@"Can't Save! %@ %@", error, [error localizedDescription]);
}

[self dismissViewControllerAnimated:YES completion:nil];
} 

但我想知道,是否可以实现,而无需实现它的提取方法,可以查看哪些数据保存在我的数据模型中?

从Coredata获取:

enter image description here

最佳答案

是。我们可以看到保存的数据而无需提取is。
实施Save方法后,核心数据将sql文件保存在Document Directory中。

您可以使用此行在nslog中打印它。

 NSLog(@"%@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);

这样您就可以看到在日志中打印的文档文件夹的完整路径。

2015-10-13 12:40:51.253 MyStore [1860:69256] file:/// Users / username / Library / Developer / CoreSimulator / Devices / C548BFA2-7B92-42E6-9D64-E16AFF0645D9 / data / Containers / Data / Application / 9C24913C-B295-4AA1-8DE9-A261CAA21624 / Documents /

那么您必须进入该文件夹。选择 G0->转到文件夹... 选项。

enter image description here

然后在转到文件夹窗口中打印文档路径。

enter image description here

注意:-您只需要在转到文件夹中编写此代码。 (来自〜/ Library)
~/Library/Developer/CoreSimulator/Devices/C548BFA2-7B92-42E6-9D64-E16AFF0645D9/data/Containers/Data/Application/9C24913C-B295-4AA1-8DE9-A261CAA21624/Documents

然后按 GO 按钮。

您将找到您的sqlfile。

enter image description here

使用某些sqllite阅读器软件打开它。

SQL Lite pro这是读取.sql文件的最佳软件。使用它打开文件。

您将在其中看到保存的数据。

enter image description here

关于ios - IOS核心数据。是否可以在不获取数据的情况下查看已保存的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33096022/

相关文章:

objective-c - 将filteredArrayUsingPredicate应用于多维NSMutableArray的特定列

iphone - 在 UINavigationBar 中居中 UILabel

ios - 核心数据 PerformBlockAndWait 没有自动释放轮询

ios - 具有序列顺序的 Coredata 获取请求

ios - 没有版本控制的 CoreData 迁移

iOS 解析验证用户

iphone - 关于 UIView 的 setNeedsDisplay 的困惑

ios - 我可以将 Apple Universal Links 与 HTTP 服务器一起使用吗?

iOS——访问 block 内的本地变量

ios - 快速移动多个物体