Where to save the .plist file in iphone application

I am developing an application for the iPhone in which I want to use the .plist file to save some configuration variables.

in my xcode, where can I create this .plist file and how to get it ???

Thank you,

+5
source share
7 answers

You put in the resources folder. Then use something like this to load it:

NSString *file = [[NSBundle mainBundle] pathForResource:@"TwitterUsers" ofType:@"plist"];
NSArray *Props = [[NSArray alloc] initWithContentsOfFile:file];

Where TwitterUsers is the name of your plist file.

If your plist file contains keys and values, you should make a second line NSDictionary instead of NSArray.

+6
source

plist "", plist , "".

Documents:

NSArray *paths = 
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 
                                    NSUserDomainMask, YES); 
NSString *documentsPath = [paths objectAtIndex:0]; 

// <Application Home>/Documents/foo.plist 
NSString *fooPath = 
[documentsPath stringByAppendingPathComponent:@"foo.plist"];
+6

Resources , . NSBundle pathForResource:ofType: , NSDictionary dictionaryWithContentsOfFile:.

: , (, ):

NSString *path = [[NSBundle mainBundle] pathForResource:@"MyConfig" ofType:@"plist"];
NSDictionary *myConfig = [NSDictionary dictionaryWithContentsOfFile:path];
+3

" " . , .

NSUserDefaults , .

.plist , , .

.plist, Documents, , , .. . NSFileManager.

+3

, plist ( "" ), XCode , pathForResource. , , , ...

+1

sqlite..... silte "".... , prcess

0
  • ?

  • plist iTunes, ?

0

All Articles