Dan
Dan

Reputation: 1110

Xamarin iOS not using constructor

I am trying to use Xamarin live to test my app on my iPhone, the issue is it doesn't seem to be using the constructor.

My AppDelegate.cs is

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
        string fileName = "books_db.sqlite";
        string fileLocation = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "..", "Library");
        string full_path = Path.Combine(fileLocation, fileName);

        global::Xamarin.Forms.Forms.Init();
        LoadApplication(new App(full_path));

        return base.FinishedLaunching(app, options);
}

Then in the main class I have 2 constructors App() and App(string db_path); it is supposed to use the one with the parameter, but it uses the App() one.

Side question, am I using the right location to store users data, it is used to store a session token

Edit:

I make it use the default constructor that doesn't have parameters, but now it says

Uncaught Exception Value cannot be null. Parameter name: image (ArugmentNullException)

The only thing that prints out is the Debug Output

Upvotes: 2

Views: 391

Answers (1)

Hichame Yessou
Hichame Yessou

Reputation: 2708

I would use the built-in Property dictionary to store the session token.

Application.Current.Properties ["token"] = session;

I wouldn't suggest you pass the path of the location to the App.cs of the PCL/Shared project, it won't work on an eventual Android project.

Upvotes: 1

Related Questions