0

I have this code who create a new database file:

// Get the documents directory NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *docsDir = dirPaths[0]; // Build the path to the database file databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent:@"registros.db"]]; NSLog(@"DB Path: %@", databasePath); 

This code always create in this directory:

DB Path: /Users/williamlima/Library/Application Support/iPhone Simulator/7.0.3/Applications/0E94A6EA-B72F-4A11-88A9-EC8C1A55BF17/Documents/registros.db

Unfortunately I could not find this file and try to open the file manager. SQL, I would like to at least try to find this file, up or maybe try to modify some command in my code for this file to be created within the folder next to the files. h / .m / .xib, I'm still a beginner in this language, then, is this possible?

3
  • You don't show any code where you are actually creating that file so maybe thats why you can't find it? Commented Mar 15, 2014 at 16:35
  • Your code only log's the path to the Documents directory, it doesn't actually write a file to that directory. Commented Mar 15, 2014 at 16:44
  • It should not give you this path, because in searchpath for direcrories. You are searching for document directory. Print this docDir and check?? Commented Mar 15, 2014 at 16:57

1 Answer 1

0

The files .h /.m / .xib are in your project and they get compiled (.m and .xib) and packaged into app. This app is installed on simulator. So first of all you won't see these files in simulator at following location

 /Users/williamlima/Library/Application Support/iPhone Simulator/7.0.3/Applications/0E94A6EA-B72F-4A11-88A9-EC8C1A55BF17/ 

When you run the app, it will create file in Documents directory in your simulator app not in your project. That location is accessible by your code running in the app.

You can create directories which are explained in these questions:

How to make a directory iOS?

Is an iPhone app's document directory /var/mobile/Documents or /var/mobile/Library/AppName?

And then create files in those directories. I think you are confused why you don't see them in your project. The reason is it is created in the app location not in your project.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.