热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

XCode4-在哪里查找由核心数据创建的sqlite文件-XCode4-wheretolookforsqlitefilecreatedbycoredata

Ihavejuststartedusingcoredata.Iwanttosetupapre-populateddb.Ireadsomewherethatcore

I have just started using core data. I want to setup a pre-populated db. I read somewhere that core data creates a sqlite file when a core data app is run. I don't know where to look for it though.

我刚开始使用核心数据。我想设置一个预先填充的数据库。我在某处读到核心数据在运行核心数据应用程序时会创建一个sqlite文件。我不知道在哪里寻找它。

I followed the instructions over on this blog but did not find the sqlite file over the location specified directory /Users//Library/Application Support/iPhone Simulator/User/Application//Documents/ nor in the application directory.

我按照此博客上的说明进行操作,但没有在指定目录/ Users / <用户名> /库/应用程序支持/ iPhone模拟器/用户/应用程序/ <应用程序guid> / Documents / <数据库名称> 的位置找到sqlite文件。 sqlite>也不在应用程序目录中。

here is my code for persistentCoordinator.

这是我的persistentCoordinator代码。

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
    if (__persistentStoreCoordinator != nil)
    {
        return __persistentStoreCoordinator;
    }

    NSString *storePath = [[[self applicationDocumentsDirectory] path] stringByAppendingPathComponent:@"coredata.sqlite"];
    NSFileManager *fileManager = [NSFileManager defaultManager];
    if (![fileManager fileExistsAtPath:storePath]) {
        NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:@"coredata" ofType:@"sqlite"];
        if (defaultStorePath) {
            [fileManager copyItemAtPath:defaultStorePath toPath:storePath error:NULL];
        }
    }

    NSURL *storeURL = [NSURL fileURLWithPath:storePath];
    NSDictionary *optiOns= [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];

    NSError *error = nil;
    __persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
    if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error])
    {
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }    

    return __persistentStoreCoordinator;
}

4 个解决方案

#1


16  

Those files are in ~/Library/Application Support/iPhone Simulator/[SDK version]/Applications/[App GUID]/Documents for me, both for Xcode 3 and Xcode 4.

对于Xcode 3和Xcode 4,这些文件都在〜/ Library / Application Support / iPhone Simulator / [SDK版本] / Applications / [App GUID] / Documents中。

If you have multiple SDKs, make sure to look in all the different SDK version directories for your app.

如果您有多个SDK,请务必查看应用的所有不同SDK版本目录。

#2


1  

For me it was in whatMuregSaid/[Application Guid]/Library/Application Support/[AppName]/filename.sqlite

对我来说,它是在whatMuregSaid / [Application Guid] / Library / Application Support / [AppName] /filename.sqlite

#3


1  

Follow these steps:

跟着这些步骤:

  1. In your applicationDocumentsDirectory function in AppDelegate.swift add this code:

    在AppDelegate.swift的applicationDocumentsDirectory函数中添加以下代码:

    let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)

    let urls = NSFileManager.defaultManager()。URLsForDirectory(.DocumentDirectory,inDomains:.UserDomainMask)

    // Look for this in the console, this will print out the location of the sqlite database, which you can then open with an SQLite viewer

    //在控制台中查找,这将打印出sqlite数据库的位置,然后可以使用SQLite查看器打开它

    print("urls.last \(urls.last)")

  2. Look for this in the console, this will print out the location of the sqlite database, open your terminal and open whatever_the_location_path_was

    在控制台中查找,这将打印出sqlite数据库的位置,打开终端并打开whatever_the_location_path_was

  3. Download SQLite viewer http://sqlitebrowser.org/

    下载SQLite查看器http://sqlitebrowser.org/

  4. Right click the yourapp.sqlite file in the folder, choose Open With sqlitebrowser that you downloaded

    右键单击文件夹中的yourapp.sqlite文件,选择Open With您下载的sqlitebrowser

Cheers!

#4


0  

hope this will help you little more

希望这对你有所帮助

  1. /Users/Username/ then press cmd+shift+G and write /Users/Username/Library, Now you will see Library folder after it go to Application Support/iPhone Simulator/7.1(or 7.1-64)/Applications/F84D4CC8-326E-4A2E-8A37-F1A755D6FCC4/Documents you will see three file and one is .sqlite file.

    / Users / Username /然后按cmd + shift + G并写入/ Users / Username / Library,现在您将看到Library文件夹,然后转到Application Support / iPhone Simulator / 7.1(或7.1-64)/ Applications / F84D4CC8-326E -4A2E-8A37-F1A755D6FCC4 / Documents您将看到三个文件,一个是.sqlite文件。

  2. To see structure and other information of this sqlite file , the most efficient way is use SQLITE MANAGER(add on of firefox https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/) add it and then click TOOL .

    要查看此sqlite文件的结构和其他信息,最有效的方法是使用SQLITE MANAGER(添加firefox https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/)添加它和然后单击工具。


推荐阅读
  • 在真实开发中,因为需求是不断变化的,说不定什么时候就需要往模型里添加新的字段,添加新的模型,甚至是大规模的重构; ... [详细]
  • IhaveconfiguredanactionforaremotenotificationwhenitarrivestomyiOsapp.Iwanttwodiff ... [详细]
  • iOS Swift中如何实现自动登录?
    本文介绍了在iOS Swift中如何实现自动登录的方法,包括使用故事板、SWRevealViewController等技术,以及解决用户注销后重新登录自动跳转到主页的问题。 ... [详细]
  • 本文介绍了lua语言中闭包的特性及其在模式匹配、日期处理、编译和模块化等方面的应用。lua中的闭包是严格遵循词法定界的第一类值,函数可以作为变量自由传递,也可以作为参数传递给其他函数。这些特性使得lua语言具有极大的灵活性,为程序开发带来了便利。 ... [详细]
  • 基于layUI的图片上传前预览功能的2种实现方式
    本文介绍了基于layUI的图片上传前预览功能的两种实现方式:一种是使用blob+FileReader,另一种是使用layUI自带的参数。通过选择文件后点击文件名,在页面中间弹窗内预览图片。其中,layUI自带的参数实现了图片预览功能。该功能依赖于layUI的上传模块,并使用了blob和FileReader来读取本地文件并获取图像的base64编码。点击文件名时会执行See()函数。摘要长度为169字。 ... [详细]
  • HDU 2372 El Dorado(DP)的最长上升子序列长度求解方法
    本文介绍了解决HDU 2372 El Dorado问题的一种动态规划方法,通过循环k的方式求解最长上升子序列的长度。具体实现过程包括初始化dp数组、读取数列、计算最长上升子序列长度等步骤。 ... [详细]
  • [译]技术公司十年经验的职场生涯回顾
    本文是一位在技术公司工作十年的职场人士对自己职业生涯的总结回顾。她的职业规划与众不同,令人深思又有趣。其中涉及到的内容有机器学习、创新创业以及引用了女性主义者在TED演讲中的部分讲义。文章表达了对职业生涯的愿望和希望,认为人类有能力不断改善自己。 ... [详细]
  • 后台获取视图对应的字符串
    1.帮助类后台获取视图对应的字符串publicclassViewHelper{将View输出为字符串(注:不会执行对应的ac ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
  • 猜字母游戏
    猜字母游戏猜字母游戏——设计数据结构猜字母游戏——设计程序结构猜字母游戏——实现字母生成方法猜字母游戏——实现字母检测方法猜字母游戏——实现主方法1猜字母游戏——设计数据结构1.1 ... [详细]
  • 利用Visual Basic开发SAP接口程序初探的方法与原理
    本文介绍了利用Visual Basic开发SAP接口程序的方法与原理,以及SAP R/3系统的特点和二次开发平台ABAP的使用。通过程序接口自动读取SAP R/3的数据表或视图,在外部进行处理和利用水晶报表等工具生成符合中国人习惯的报表样式。具体介绍了RFC调用的原理和模型,并强调本文主要不讨论SAP R/3函数的开发,而是针对使用SAP的公司的非ABAP开发人员提供了初步的接口程序开发指导。 ... [详细]
  • java.lang.Class.getDeclaredMethod()方法java.lang.Class.getDeclaredMethod()方法用法实例教程-方法返回一个Met ... [详细]
  • UIView的通用动画letviewUIView(frame:CGRectMake(10.0,10.0,100.0,40.0))self.view.addSubview(vie ... [详细]
  • swift中的uitable
    下面是一个静态的tableview于图可知有两个section头是11..和22..,其中222是一个tableviewcell!并且从图可知道样式是leftD ... [详细]
  •   源码地址:https:github.comfzhleeSwiftUI-Guide当点击按钮时,弹出Modl模态窗口。示例代码:structContentView:View{@S ... [详细]
author-avatar
讨厌上学的-彭志超-_354
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有