Reputation: 91
I am currently working on a MonoTouch project and needed to add in an Objective C API for use with a card reader. I am having some difficulty understanding the basics of getting the binding working after reading all of the documents provided by Xamarin. I am trying to code for an interface and I am getting mixed messages regarding how to code the C# versions of the methods. I've seen ways of doing it where you actually call the Objective C Runtime using handles and all that jazz, like so:
[Export("doSomething")]
public virtual void DoSomething()
{
return Runtime.GetNSObject(
Messaging.IntPtr_objc_msgSend(this.Handle, selNextObject.Handle));
}
// I know this code doesn't match what you would do in a void method
// but bear with me
but I've also seen examples creating method definitions as simple as
//from obj-c code -(void) doSomething;
[Export("doSomething")]
void DoSomething();
Does the method automatically recognize the 'doSomething' method in the Objective C API and carry out those operations or do I have to code the C# method operations myself somehow? (I am aware of Selectors, but I am not very familiar with them or what they do/how to properly use them) I would appreciate any help or explanations possible. Thanks so much!
Upvotes: 0
Views: 310
Reputation: 32694
If you use the binding generator, it does all the work for you. This is what we use for almost every bit of API in MonoTouch.
But if you want to roll things out by hand, you manually call msgSend
Upvotes: 1