[enter image description here][1]I get three values from JSON. How do I store those three values in NSString
and then store those strings locally i.e on the device?
I tried NSUserDefaults
but I'm unable to do it. I've attached the code snippet.
NSData *JSONData = [NSJSONSerialization dataWithJSONObject:responseObject
options:0 // Pass 0 if you don't care about the readability of the generated string
error:&error];
if (! JSONData)
{
NSLog(@"Got an error: %@", error);
} else {
//_branchId = [responseObject valueForKey:@"branchId"];
_branchName = [responseObject valueForKey:@"branchName"];
_branchUri = [responseObject valueForKey:@"branchUri"];
[[NSUserDefaults standardUserDefaults] setObject:_branchId forKey:[responseObject valueForKey:_branchId]];
[[NSUserDefaults standardUserDefaults] setObject:_branchName forKey:@"branchName"];
[[NSUserDefaults standardUserDefaults] setObject:_branchUriStore forKey:@"_branchUri"]; // Here the setobject value remains nil only
[[NSUserDefaults standardUserDefaults] synchronize];
PS: I want to use that stored value in my commonutility also. How to do that as well?
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"(__fetchBranchUri)/%@",url]]];