Reputation: 1240
I have a binding for Bluetooth BLE device with the following binding:
[BaseType (typeof (CBPeripheralDelegate), Delegates=new string [] {"WeakDelegate"},
Events=new Type [] { typeof (BrspDelegate) })]
interface Brsp
{
//@property (nonatomic, weak) id <BrspDelegate> delegate;
[Export ("delegate")]
[NullAllowed]
BrspDelegate Delegate { get; set; }
[Wrap ("WeakDelegate")]
[NullAllowed]
NSObject WeakDelegate { get; set; }
...other stuff
}
And the following delegate:
[BaseType(typeof(NSObject))]
[Model]
interface BrspDelegate
{
[Abstract]
[Export("brsp:OpenStatusChanged:"), EventArgs("OpenStatus")]
...other stuff
}
When I hook up a generated event handler for the openstatuschanged, it instantly crashes the app and I get no feedback whatsoever what could be wrong. I'm still a newbie to binding, so...
I have the feeling somehow I made mistake with "Events = ..." part, any ideas?
Thanks,
Rogier
Upvotes: 2
Views: 208
Reputation: 43553
Hard to say without more details (e.g. symbolicated crash log) but part of your bindings are inverted (and that could cause endless recursion that will crash your app).
Delegate
method should have the [Wrap]
attribute (on WeakDelegate
); andWeakDelegate
method should be the one with the [Export]
attribute on the delegate
selector.E.g.
[Wrap ("WeakDelegate")]
StronglyTypedDelegate Delegate { get; set; }
[Export ("delegate")][NullAllowed]
NSObject WeakDelegate { get; set; }
Upvotes: 2