Note to myself: Never ever call any member of a base class like "View" or "TableView" within your controllers constructor, if you depend on fields in your ViewDidLoad() method set later there.
Bad example:
public class MyController : UITableViewController
{
private string _title;
public MyController(string title)
{
View.BackgroundColor = UIColor.White;
_title = title;
}
public override void ViewDidLoad()
{
Console.WriteLine(_title); // IS NULL!
}
}
I was hunting that ghost for half an hour and remembered that I did run into that phenomenon a year or so ago. After some search I found the answer of Rolf Bjarne Kvinge he gave me in those days, too:
"This usually happens when in a base class you call a virtual property, which ends up calling a virtual member on the derived class.
This is easy to see if you get a stack trace in the virtual method (such as ViewDidLoad) in the derived class, in which case you'll easily see what's happening."
Or in other words: If you do what I did in my example, ViewDidLoad() will always be called before _title is set - from within your constructor, what looks like the constructor is called afterwards.
What a waste of time ;-).