iosxamarinobjective-c-blocksinfobip

Xamarin iOS bind library with blocks


I'm trying to bind Infobips Objective-C library to Xamarin. But I get stuck on this block:

+ (void)shareLocation:(CLLocation *)userLocation withBlock:(IPResponseBlock)block;

I've never used Blocks in Objective-C and don't really understand how this should be mapped to C#.

Can anybody help me figure this out?

Regards//Lars


Solution

  • Let me break it down for you:

    enter image description here

    Notice how similar is the syntax between lambdas and blocks:

    (args) => {
    //  implementation code
    };
    

    (void) = ^{
            NSLog(@"This is a block");
        };
    

    Now, for the binding part, Xamarin provides a easy to use documentation: Binding Objective-C Libraries