I'm trying to make a 'saveState' method with implementation (in blablabla.m):
-(void)saveState {
NSString *masterCode = [[NSString alloc] initWithString:first];
masterCode = [masterCode stringByAppendingString:second];
masterCode = [masterCode stringByAppendingString:third];
masterCode = [masterCode stringByAppendingString:fourth];
NSLog(@"master passcode - %@", masterCode);
NSString *plistPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"timeLimiterMasterCode.plist"];
if (![[NSFileManager defaultManager] fileExistsAtPath:plistPath]) {
[[NSFileManager defaultManager] createFileAtPath:plistPath contents:nil attributes:nil];
}
if ([[NSFileManager defaultManager] fileExistsAtPath:plistPath]) {
NSLog(@"file exists, %@", plistPath);
}
NSMutableDictionary *plistCode = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath];
[plistCode setObject:masterCode forKey:@"MasterCode"];
NSLog(@"whole plist - %@", plistCode);
[plistCode writeToFile:plistPath atomically: YES];
NSLog(@"master passcode from file - %@", [plistCode objectForKey:@"MasterCode"]);
}
masterCode is not nill, in blablabla.h file I'm using protocol UIApplicationDelegate, "file exists" but application returns: 2013-01-29 12:19:50.496 timeLimiter[916:907] whole plist - (null) 2013-01-29 12:19:50.500 timeLimiter[916:907] master passcode from file - (null)
Besides in viewController (.m, .h) I use another plist and write method and the work correctly.
I found that [plistCode setObject:masterCode forKey:@"MasterCode"] is hill. I've tried to replace 'masterCode' with @"test" but it did no sense.
Could you solve my issue? Please?