简体   繁体   English

我的数据库文件在xcode项目中的哪里

[英]Where is my database file in xcode project

After I build an app with sqlite . 在我使用sqlite构建应用程序之后。 I have installed SQLite manager in Firefox. 我已经在Firefox中安装了SQLite管理器。 Doesn´t help because I really don´t know where is that file. 没有帮助,因为我真的不知道该文件在哪里。 I tried many ways. 我尝试了很多方法。 And finally I try to find this file 最后我尝试找到这个文件

 _databasePath = [[NSString alloc] initWithString:[docsDir stringByAppendingPathComponent:@"myUsers.db"]];

To open with MesaSQLite Still have the same problem. 用MesaSQLite打开仍然有同样的问题。 Where is my file. 我的文件在哪里。

Here is the last way I have used: 这是我使用过的最后一种方法:

/Users/{YOUR NAME}/Library/Developer/CoreSimulator/Devices/{DEVICE ID}/data/Containers/Data/Application/{APPLICATION ID}/

I still can not find it. 我仍然找不到它。 I have open almost every project folders. 我几乎打开了每个项目文件夹。 Please help me. 请帮我。

Dont open Library on MacintoshHDD. 不要在MacintoshHDD上打开库。 You need to open Library on your USERName Folder. 您需要在USERName文件夹上打开“库”。 There,normally library folder is hidden. 在那里,通常库文件夹是隐藏的。 You need to follow the following to see the hidden files. 您需要按照以下步骤查看隐藏的文件。

Or simply copy paste the path into the search finder on your mac.It will take you directly. 或者直接将路径复制粘贴到Mac上的搜索器中,它将直接带您进入。

The long way to show hidden Mac OS X files is as follows: 显示隐藏的Mac OS X文件的很长的方法如下:

     Open Terminal found in Finder > Applications > Utilities.

In Terminal, paste the following: 在终端中,粘贴以下内容:

      defaults write com.apple.finder AppleShowAllFiles YES.
           Press return.
       Hold 'alt' on your keyboard, then right click on the Finder icon in the dock and click Relaunch.

You should be able to find this using this method : 您应该可以使用以下方法找到它:

- (NSURL *)applicationDocumentsDirectory
{
    NSLog(@"%@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory  inDomains:NSUserDomainMask] lastObject]);

    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
 }

Just copy paste whatever is logged in navigate into the folder where you stored your sqlite file 只需复制粘贴任何已登录的内容,导航到存储sqlite文件的文件夹中

The end result should look like this : 最终结果应如下所示:

~/Library/Developer/CoreSimulator/Devices/4D2D127A-7103-41B2-872B-2DB891B978A2/data/Containers/Data/Application/0323215C-2B91-47F7-BE81-EB24B4DA7339/Documents/MyApp.sqlite

Please note that the long ID's will obviously be different, as well as the file name. 请注意,长ID以及文件名显然会有所不同。

You just following line of code to Log. 您只需遵循以下代码行即可登录。

NSString *databasePath = [[NSBundle mainBundle] pathForResource:@"myUsers" ofType:@"db"];

Or use below code. 或使用下面的代码。

NSBundle* bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"myUsers" ofType:@"bundle"]];
NSLog(@"%@", bundle);
NSString* test = [bundle pathForResource:@"myUsers" ofType:@"db"];
NSLog(@"%@", test);
NSDictionary* dict = [NSDictionary dictionaryWithContentsOfFile:[bundle pathForResource:@"Root" ofType:@"plist"]];
NSLog(@"%@", dict);

I am using the Core Data Editor a lot for my iOS projects. 我在iOS项目中经常使用Core Data Editor It is compatible with Mac and iOS applications and support XML, SQLite and binary stores, etc. It is free. 它与Mac和iOS应用程序兼容,并支持XML,SQLite和二进制存储等。它是免费的。 :-) :-)

http://thermal-core.com/CoreDataEditor/ http://thermal-core.com/CoreDataEditor/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM