Hello,
I had asked a qestion whether I should use a Plist here :
http://www.iphonedevsdk.com/forum/ip...tml#post244057
Thanks for the response
I have still decided to make use of PList
Here is what I have coded :
Code:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES );
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fileWithPath = [documentsDirectory stringByAppendingPathComponent:@"appConfig.plist"];
// I then check if the file exists
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:fileWithPath];
//if this file does not exist then I know user has just installed the application
//so I create the file and store some flag in it
if (!(fileExists)){
NSString *firstTimeFlag = @"TRUE";
NSMutableArray *appConfigArray = [[NSMutableArray arrayWithCapacity:1] retain];
NSArray *keys = [NSArray arrayWithObjects:@"firstTimeFlag",nil];
[appConfigArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:firstTimeFlag,nil] forKeys:keys]];
[appConfigArray writeToFile:fileWithPath atomically:YES];
This I can do
My questions are - I see that this file gets created in a wierd location :
/users / <<user >> / Library / Application Support / iPhone Simulator / 4.0.2 / applications / <<some no >> / Documents / appConfig.plist
When I reset the simulator the file is gone
Whiich is fine
when I restart the application ( without resetting the simulator) - I can detect the file which is what I want
I am wondering to maintain state this way - will it also work on iPhone
I also plan to save the state that user has logged in a application this way
Is there any thing I should be worried about ?
Will this work on iPhone or only on simulator ?
I see apple is really taking pains to make developers to go through loops
Which is how I guess they generate revenue ( already spent about usd 2500 in INdian rupees to buy an iphone and a macbook )
The frustrating thing is I will have to spend another usd 100 to register
and then too ( which I will post a separate thread) I see that I dont quite uunderstand how to do an ad hoc deployment on my phone
Anyway that is going to be a separate question for you guys here !
Please let me know your thoughts - and thanks
~ramdas