I got stuck in an issue when I was writing Xamarin Binding Library.
Prerequisites
- I have iOS Native Framework.
- I have a Xamarin Forms Application.
I have to write Xamarin Binding Library, which I am successfully able to write.
Now I got stuck
iOS Native Framework API (in MyClass.h) :-
-(void)clearAllDishes:(NSError * _Nullable * _Nullable)error;
Binding Code API (in ApiDefination.cs) :-
[BaseType(typeof(NSObject))]
public interface MyClass
{
// -(void)clearAllDishes:(NSError * _Nullable * _Nullable)error;
[Export("clearAllDishes:")]
void ClearAllDishes([NullAllowed] out NSError error);
}
Now in Xamarin UI we have to call below method :-
try {
MyClass obj = new MyClass();
obj.clearAllDishes()
} catch throws Custom Exception {
// Assuming the MyClass will throw the exception, when NSError pointer passed in iOS Native Framework.
}
Now my requirement is from Xamarin UI I have to call a method clearAllDishes()
and further in Xamarin Library Binding I have to handle the clearAllDishes()
in such a way so that we can throw the exception to Xamarin UI from here and call the iOS Native API clearAllDishes
.