To save a UIImage
to a PNG or JPEG locally you call the asPNG().Save(...)
function.
The asPNG().Save()
function requires an out NSError
The problem is that you can no longer just create a blank NSError to pass in like this (Obsolete
)
NSError err = new NSError(); //Obsolete
So, to use the Save() function in MonoTouch, how do we create an NSError() object now?
In .NET you do not have to initialize any out
parameter (in contrast to ref
parameters) since it's the called method job to do so.
E.g.
NSError err; // unitialized
UIImage img = ...;
img.AsPNG ().Save (url, true, our err);
if (err != null && err.Code != 0) {
// error handling
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With