How to save the current state of the application

I am making an iphone application in which, after logging in, we will go through a few steps, and then finally make a call from the application. As we know, when the application is called, our application terminates, so does the PLZ prompt me to resume this state when the application is restarted?
1-Login
2-several steps
3-list of
4-call numbers

Any help would be appreciated. Thanx ..

+3
source share
3 answers

Preservation

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

// save NSString

[prefs setObject:@"TextToSave" forKey:@"keyToLookupString"];

// save NSInteger

[prefs setInteger:42 forKey:@"integerKey"];

// save double

[prefs setDouble:3.1415 forKey:@"doubleKey"];

// save the float

[prefs setFloat:1.2345678 forKey:@"floatKey"];

[prefs synchronize];

Getting

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

// get NSString

NSString *myString = [prefs stringForKey:@"keyToLookupString"];

// get NSInteger

NSInteger myInt = [prefs integerForKey:@"integerKey"];

// get float

float myFloat = [prefs floatForKey:@"floatKey"];
+3
source

Apple , iphone. iphone , , .

( , , pagestate ..), .

, , .

iphone SDK iphone? iphone SDK.

+2

In general, NSUserDefaultsit is very useful for this kind of thing - as a very simple example, you can save int, which records the state of the application on exit.

0
source

Source: https://habr.com/ru/post/1742575/


All Articles