Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

In Obj-C Binding: What type should I map CLLocationCoordinate2D[] in argument?

$
0
0

Hello,

Now I'm binding Objective-C library to Xamarin.

There are some methods having CLLocationCoordinate2D[] as argument, example:

-(id)initWithCoordinates:(CLLocationCoordinate2D[])coordinates count:(unsigned int)count;

Objective Sharpie map this

IntPtr Constructor ([unmapped: unexposed: IncompleteArray] coordinates, uint count);

So I fix it manually

IntPtr Constructor (CLLocationCoordinate2D[] coordinates, uint count);

But, in build phase, compiler generate intermediate code:

[Export ("initWithCoordinates:count:")]
[CompilerGenerated]
public ShapeKitPolyline (global::MonoTouch.CoreLocation.CLLocationCoordinate2D[] coordinates, global::System.UInt32 count)
    : base (NSObjectFlag.Empty)
{
    if (coordinates == null)
        throw new ArgumentNullException ("coordinates");
    var nsa_coordinates = NSArray.FromNSObjects (coordinates);

    IsDirectBinding = GetType ().Assembly == global::ApiDefinition.Messaging.this_assembly;
    if (IsDirectBinding) {
        Handle = MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_UInt32 (this.Handle, selInitWithCoordinatesCount_Handle, nsa_coordinates.Handle, count);
    } else {
        Handle = MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_IntPtr_UInt32 (this.SuperHandle, selInitWithCoordinatesCount_Handle, nsa_coordinates.Handle, count);
    }
    nsa_coordinates.Dispose ();

}

CLLocationCoordinate2D is value type, so cannot cast to NSArray's element, so build failed.

But, I think Obj-C's original method requires CLLocationCoordinate2D[] (value type), so that auto-generated code gives NSArray as it's argument causes error, isn't it?

I confused what C# type should I map as CLLocationCoordinate2D[].


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>