Accessing public fields that were declared in a library

BernieHabermeierBernieHabermeier USUniversity ✭✭

There is a nice section in the docs "Binding Fields" that talks about how to bind global variables from a library. But it comes with some restrictions on the types it supports: 32 and 64 bit ints and floats, CGSize, and System.Drawing.SizeF, along with some read-only NSString and NSArray.

That leads some to wonder how to bind global fields from a library that fall outside of the list of supported types?

There was a similar question already here about how to bind a c-like array of characters. And @RolfBjarneKvinge said to use IntPtr -- which is great. But what about any other type? For example, I'm attempting to bind UrabanAirship for iOS, and they have a bool that needs binding. I doubt an IntPtr makes sense in this case:

partial interface Constants
{
    [Field("uaLoggingEnabled", "__Internal")]
    bool uaLoggingEnabled { get; }

    [Field("uaLogLevel", "__Internal")]
    UALogLevel uaLogLevel { get; }

    [Field("uaLoudImpErrorLoggingEnabled", "__Internal")]
    bool uaLoudImpErrorLoggingEnabled { get; }

}

Anyhow uaLoggingEnabled and uaLoudImpErrorLoggingEnabled are bools, and I wonder how I should be binding those.

Regardless of my specific question of how to bind bool, it would be great if there could be a section in the how-to for binding_objc_libs that goes over what to do in case you need to bind something that falls outside the supported types in general. What is the workaround? I assume IntPtr works for most pointer types... but it would be nice for a small section on what to do generally if the type is not supported...

Posts

  • MichaelBluesteinMichaelBluestein USInsider, University, Developer Group Leader ✭✭✭

    "...it would be nice for a small section on what to do generally if the type is not supported..."

    @CraigDunn can you guys add a section for this to the binding doc?

Sign In or Register to comment.