"Problem Collection • Primary problem" simulator and real machine, how to specify the database path, the simulator and the real machine corresponding sandbox is different ...

Source: Internet
Author: User

Simulator and real machine, how to specify the database path, the simulator and the real machine corresponding sandbox is different ...

The user's question is as follows: at:£ º

But the principle does not understand very much ...

The user's question is as follows: at::

I used a database framework in the project to manipulate the database is encapsulated in this framework

The user's question is as follows: at:

I looked at my head file.

The user's question is as follows: xx:

Is that the database specifies a path at initialization time, which is the sandbox path of the emulator runtime.

my answer is as follows: xx:from:

Well, the path to the database on the real machine can be set up?

The user's question is as follows: xx:

Then the database file generated after the project is run with the emulator is xxx.db

my answer is as follows: xx:from:

#define Cylaccountpath [Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES) [0 ] stringbyappendingpathcomponent:@"Account.data"]

my answer is as follows: xx:from:

Is it like this?

The user's question is as follows: xx:from £ º

This file will be stored in the Documents folder

my answer is as follows: xx:

Well, yes.

The user's question is as follows: xx:

Yes, yes.

The user's question is as follows: xx:

Then running this path on the real machine is not to be re-specified

my answer is as follows: xx::

This is not necessary.

The user's question is as follows: xx::

Why is it?

my answer is as follows: xx::

There are two types of paths, one is an absolute path, such as /users/chenyilong/desktop/asdfsd.db, and the other is the one we just used. If the former, we run on the Mac simulator, want to run on the real machine is the need to re-write the path.

my answer is as follows: xx::

#define Cylaccountpath [Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES) [0 ] stringbyappendingpathcomponent:@"Account.data" This method is to get the sandbox path for iOS devices and is designed for iOS devices , and the simulator is able to run successfully because it simulates the environment of the real machine.

The user's question is as follows: xx:

Well, I'm telling you, the path hasn't changed, and there's no problem.

my answer is as follows: xx:Wuyi

This approach is designed for IOS device iphone-ipad . So no need to change the real machine at any time. The emulator can run, only to show that Apple 's simulator is very powerful, analog iOS device simulation is exactly the same, let the compiler think it is running on the IOS device

The user's question is as follows: xx:Panax Notoginseng

The problem is that the project has a need to ensure that one of the tables in the database has two data

my answer is as follows: xx::

is two tables in a db ? Or what?

The user's question is as follows: xx:

The first thing I did was to have the project run on the emulator to generate a . db database file, put the file in the project, and then reassign dbpath to nsbundle mainbundle、、、

The user's question is as follows: xx:one:

Let the program find this file to load the data in the database table

my answer is as follows: xx:one:

Well, you should know now that's not necessary.

The user's question is as follows: xx:

And then I wrote a copy of the file that actually proves that it doesn't work ...

The user's question is as follows: xx:

Finally, I specify the simulator sandbox path is not a problem at the moment ...

my answer is as follows: xx:

Don't worry, there's no problem.

my answer is as follows: xx:

my answer is as follows: xx:£ º

Simulator sandbox path is changed to true machine sandbox path

The user's question is as follows: xx:

Project packaged into apk to get another device installed should it be no problem?

my answer is as follows: xx:

It won't be a problem to pack into an IPA .

The user's question is as follows: xx:

Which means Simulator's The documents path and the documents under the real machine are a path

The user's question is as follows: xx::

Can you understand this?

my answer is as follows: xx::

Right

The user's question is as follows: xx:

Well, that's good, it's got a harvest today!

my answer is as follows: xx:

Our approach, which points to actually the sandbox path of the IOS device. MAC computer system is not supported, but because the simulator simulation environment is too realistic,Xcode thought it was running on the real machine, so also successfully pointed to a folder on the computer.

my answer is as follows: xx:Ten

Okay, I'll talk to you at any time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.