Note that there are some explanatory texts on larger screens.

plurals
  1. POOBJ. C. (XCODE 5 - IOS 7) Auto save variables in a property list
    primarykey
    data
    text
    <p>I want to save automatically my variables (floats) in a property list that I've already create. I can do that with a button, that work good but I want to do that automatically WITH IOS 7 (some methods are deprecated in IOS 6 or 7). </p> <pre><code>replyToApplicationShouldTerminate </code></pre> <p>doesn't work... </p> <p>I save in the property list with a button like that:</p> <pre><code>-(IBAction)apply:(id)sender { { [nameC1 resignFirstResponder]; [nameC2 resignFirstResponder]; [nameC3 resignFirstResponder]; [nameC4 resignFirstResponder]; [nameC5 resignFirstResponder]; nom1 = [nameC1 text]; nom2 = [nameC2 text]; nom3 = [nameC3 text]; nom4 = [nameC4 text]; nom5 = [nameC5 text]; v1 = [NSString stringWithFormat:@"%d", compteur1]; v2 = [NSString stringWithFormat:@"%d", compteur2]; v3 = [NSString stringWithFormat:@"%d", compteur3]; v4 = [NSString stringWithFormat:@"%d", compteur4]; v5 = [NSString stringWithFormat:@"%d", compteur5]; //Write in Data.plist NSString *error; NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *plistPath = [rootPath stringByAppendingPathComponent:@"Data.plist"]; NSDictionary *plistDict = [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects: nom1, nom2, nom3, nom4, nom5, v1, v2, v3, v4, v5, nil] forKeys:[NSArray arrayWithObjects: @"nomCompteur1", @"nomCompteur2", @"nomCompteur3", @"nomCompteur4", @"nomCompteur5", @"valeurCompteur1", @"valeurCompteur2", @"valeurCompteur3", @"valeurCompteur4", @"valeurCompteur5",nil]]; NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:plistDict format:NSPropertyListXMLFormat_v1_0 errorDescription:&amp;error]; if(plistData) { [plistData writeToFile:plistPath atomically:YES]; } else { NSLog(@"error"); //[error release]; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload