Since memory management is fierce on mobile devices (especially iOS devices) all the lazy loading you can implement will give your app a better memory footprint.
Although Xamarin.iOS / Mono has quite a good Garbage Collection level (either SGen or Boehm) every Image that isn’t needed beforehand will only take up memory if defined on a global scale (like in the AppDelegate, as propery in some sort of container class, etc…)
So how would you feel lazy loading all the about variables, images, even class instances (objects) that you might eventually use, but not upfront?
This is easily implemented using the Lazy
[crayon-610a64932308a576286360/] As soon as the myClassObject is used somewhere, the Lazy class will initiate the MyClass’s constructor and get your object into the myClassObject variable.
The same goes for images and alike:
[crayon-610a649323099815173291/] And best of all: these simple instantiator functions are all thread safe! Now ain’t that something?!
Now how would you even take more advantage of this? Create a static class and add all these images and other GUI stuff into lazy variables and you can have a Theme like class that contains your entire GUI smuck. For that I won’t take the credit, check out how the guys at Xamarin made an excellent example of this in their prebuilt app called Fieldservice on Github
Boo-ya that’s awesome!