In the B Viewcontroller, I store data into NSUserDefaults and retrieve them in AViewController.
During the execution, it performs as it expected. However, once I close and re-run the app, I figure out that these information (dictionary) does not being stored.
Here is the BViewController where I store the data in NSUserDefaults
partial class BViewController : UIViewController
{
const string server = "server";
const string port = "port";
const string password = "password";
const string username = "username";
const string inboxuserid = "inboxuserid";
.............
.............
public override void ViewWillDisappear (bool animated)
{
var appDefaults = new NSDictionary (server, serverTF.Text, port, portTF.Text, password, passwordTF.Text,username,usernameTF.Text, inboxuserid,inboxuserTF.Text);
NSUserDefaults.StandardUserDefaults.RegisterDefaults (appDefaults);
NSUserDefaults.StandardUserDefaults.Synchronize ();
}
}
and retrieve them in the A ViewController as follows:
partial class AViewController : UIViewController
{
public override void ViewWillAppear(bool animated)
{
var username = NSUserDefaults.StandardUserDefaults.StringForKey ("username");
Console.WriteLine (username);
}
}