Friday, 18 April 2014

Store a Bool Value or String Value in Your App

Storing Process :
You can Store values are these methods :
setValue, setURL, setInteger, setDouble, setFloat, setBool, setObject and more........

Example :
[[NSUserDefaults standardUserDefaultssetBool:YES forKey:@"BoolValue"];
[[NSUserDefaults standardUserDefaultssynchronize];

[[NSUserDefaults standardUserDefaultssetObject:@"str" forKey:@"key"];
[[NSUserDefaults standardUserDefaultssynchronize];

[[NSUserDefaults standardUserDefaultssetInteger:12 forKey:@"Int"];
[[NSUserDefaults standardUserDefaultssynchronize];

Retrive Process :
Example 1:
NSString *String_Str = [[NSUserDefaults standardUserDefaults]boolForKey:@"BoolValue"];
if (!String_Str)
{
        //Code
}
else
{
       //Code
}

Example 2:
NSString *String_Str1 = [[NSUserDefaults standardUserDefaults]boolForKey:@"key"];
NSLog(String_Str1);

No comments: