Friday, June 08, 2012

NSUserDefaults

Save :

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];


// saving an NSString
[prefs setObject:@"TextToSave" forKey:@"stringKey"];


// saving an NSInteger
[prefs setInteger:100 forKey:@"integerKey"];


// saving a Float
[prefs setFloat:1.2345678 forKey:@"floatKey"];



Retrieve :

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];


// getting an NSString
NSString *myString = [prefs stringForKey:@"
stringKey"];


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

// getting an Float
float myFloat = [prefs floatForKey:@"
floatKey"];

No comments:

Create a list in SwiftUI with sticky section headers

 Sample Code import SwiftUI struct ContentView : View {     @State var isCustomViewControllerDisplayed = false     @State private va...