Reputation: 3143
I'm trying to create a binding for an iOS library.
When creating a native app with this library, it requires to include a .h header file which declares a global ApplicationKey variable like this:
extern const unsigned char ApplicationKey[];
and you are supposed to implement it
const unsigned char ApplicationKey[] = {0x11, ... };
Now, when creating the Xamarin binding for this library, the header file is mapped by Objective Sharpie to
partial interface Constants
{
// extern const unsigned char [] ApplicationKey;
[Field ("ApplicationKey")]
byte[] ApplicationKey { get; }
}
How to change it to be able to set ApplicationKey from C# code?
Upvotes: 0
Views: 590
Reputation: 556
Your ApiDefination.cs file should be like this
[BaseType (typeof(NSObject))]
public partial interface Constants
{
[Export ("ApplicationKey")]
TypeOfProperyInNativeCode ApplicationKey { get; set; }
}
in order to access this property create instance of Constant Class of binding project and access like this
Binding.Constant cons= new Binding.Constant();
cons.ApplicationKey =value;
For better understanding you can follow this link http://developer.xamarin.com/guides/ios/advanced_topics/binding_objective-c/Walkthrough_Binding_objective-c_library/
Upvotes: 1