How does the ObjectiveC code below translate into MonoTouch?
@interface PSPDFBookmarkViewController : UITableViewController <PSPDFStyleable>
- (instancetype)initWithDocument:(PSPDFDocument *)document;
@property (nonatomic, weak) id<PSPDFBookmarkViewControllerDelegate> delegate;
@property (nonatomic, assign) BOOL isInPopover;
@end
- I don’t really know what to do with the
instancetypethingy (what is this?) - What is
id<PSPDFBookmarkViewControllerDelegate>. - What to do with the
PSPDFStyleable?
This is what I think would be the result:
[BaseType(typeof(UITableViewController)]
interface PSPDFBookmarkViewController
{
void InitWithDocument(PSPDFDocument document);
[NullAllowed]
PSPDFBookmarkViewControllerDelegate Delegate { get; set; }
bool IsInPopover { get; set; }
}
And what about this interface?
@interface PSPDFBookmarkViewController (SubclassingHooks)
- (void)createBarButtonItems;
@end
What is the (SubclassingHooks) about and what is its C# cousin?
Many questions… here’s a few answers:
ObjectiveC
init*selectors are .NET constructors. So:should be like:
and your other C# bindings are missing their
[Export]attributes. E.g.Other questions:
<PSPDFStyleable>is a Objective-C protocol, which is very similar to .NET interfaces. Now if you don’t needPSPDFStyleablethen you do not have to bind it.That’s an instance that implements
PSPDFBookmarkViewControllerDelegate. You would normally bind this asPSPDFBookmarkViewControllerDelegatefor theDelegateproperty and also add aWeakDelegateso anyNSObjectthat implement the right selectors can be used. E.g.You’ll need to add
Delegates=new string [] { "WeakDelegate" }to your[BaseType]attribute. Also addEvents=if you want to turn the delegate members into events. E.g.(SubclassingHooks)is an Objective-C category, which is very similar to .NET extensions methods. That requires a bit of manual bindings with the existing generator.Finally make sure to read the binding documents that are available on Xamarin documentation portal. It’s not very complicated (your sample hits a lot of cases for very few lines) but there’s a lot of data to digest (even more if you do not know Objective-C very well).