Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MonoTouch binding issue of inheriting abstract member

Tags:

xamarin.ios

I am working on MonoTouch binding of an Objective-C application. I referred iOS Binding Walkthrough.

I have generated libraries for i386, ARM and then a universal library. Further, I created a MonoTouch Binding Project. I have generated ApiDefinition using Sharpie and added the universal library generated earlier. Now when I build this project I am getting the following error.

ADClusterAnnotation.g.cs(86,86): Error CS0533:
AnnotationClusterMap.ADClusterAnnotation.Coordinate' hides inherited abstract member MonoTouch.MapKit.MKAnnotation.Coordinate' (CS0533)

Here is the code snippet of ADClusterAnnotation:

File ADClusterannotation.h

@interface ADClusterAnnotation : NSObject <MKAnnotation> {
    CLLocationCoordinate2D  _coordinates;   
}
@property (nonatomic) CLLocationCoordinate2D coordinate;
@end

File ADClusterAnnotation.m

@synthesize coordinate = _coordinates;

Here is the code snippet from ApiDefinition

[BaseType (typeof (MKAnnotation))]
public partial interface ADClusterAnnotation {
    [Export ("coordinate")]
    CLLocationCoordinate2D Coordinate { get; set; }
}

So I think we need to change something in ApiDefinition. I tried removing Coordinate from ADClusterAnnotation in the API definition, but then it gives an error that it implements an abstract member. What am I missing with regard to Monotouch binding?

like image 972
chaitanya bhatt Avatar asked Dec 14 '25 16:12

chaitanya bhatt


1 Answers

Overriding an abstract member require c# new or override

You can get that to be generated by changing your ApiDefinition to:

[BaseType (typeof (MKAnnotation))]
public partial interface ADClusterAnnotation {
    [Export ("coordinate")]
    [New]
    CLLocationCoordinate2D Coordinate { get; set; }
}
like image 87
Stephane Delcroix Avatar answered Dec 19 '25 03:12

Stephane Delcroix