NSArray * paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
NSString * documentsDirectory = [paths objectAtIndex: 0];
return [documentsDirectory stringByAppendingPathComponent: kFilename];
} Method to find, but when I have a connection to the real machine can not find the above tests, when I tested the iphone above should be placed where the database project folder ah, because it is the customer's own download, I want to project When the iphone will be able to connect to the database at runtime, because the database has a lot of data inside, so you can not download and create your own, put the project on their own how to make the program folder under normal use, impatient, I hope a lot of care! !
Reply:
It first on the bag and then copy the past
NSString * localDBPath = [[NSHomeDirectory () stringByAppendingPathComponent: @ "Documents"] stringByAppendingPathComponent: @ "XX.db"];
if ([[NSFileManager defaultManager] fileExistsAtPath: localDBPath]!) {
NSString * bundleDBPath = [[NSBundle mainBundle] pathForResource: @ "XX" ofType: @ "db"];
[[NSFileManager defaultManager] copyItemAtPath: bundleDBPath toPath: localDBPath error: nil];
}
Reply:
I see you do not understand this code, I put viewdidload wood inside is successful execution! ! What should be placed where there is a clear tell me I novice, many do not understand, try to understand that a little hope!
Reply:
I throw in a database directly under the root directory of the project folder, there is the problem?
Reply:
Judgment is a piece of code
If you do not have this in the document database file
Put [NSBundle mainBundle] bag is app program files are copied to the document under
To advance to load the data file to the resources inside! Generated when the package will be packaged inside the
This code reads the database before you can perform the data, you can easily put
Reply:
To advance to load the data file to the resources inside! Guess you do not ⋯ ⋯
Reply:
I added to the resources inside, I copied successfully mac above, but do not replicate the success of the iphone below! In God horse iphone copy above requirements it? ?
Reply:
Is that right?
Sandbox Documents no limit ah
I have been so used.
No comments:
Post a Comment