Global Variables possible?

Okay, I know that having global variables is a bad design, but the library I'm wrapping is expecting some configuration values in global variables. That said, is it possible to do anything with these in a way that the library will understand?

In the example provided with the library, they have this global integer in the app delegate:
extern int ALLOW_UNSUPPORTED_MAIN_THREAD_OPERATIONS = 1;

I can't see any place in any of the header files where I might bind to any underlying function. I haven't figured out a way to define anything in my app delegate that is seen by the library in the same way either.

Is this possible?

Best Answer

  • MatthewNoelMatthewNoel US ✭✭
    edited June 2017 Accepted Answer

    I figured this out, for this purpose. I added this to the Constants:

    [Field("ALLOW_UNSUPPORTED_MAIN_THREAD_OPERATIONS", "__Internal")]
    int ALLOW_UNSUPPORTED_MAIN_THREAD_OPERATIONS { get; set; }
    

    Though the field doesn't show up in any of the .h files, this works anyway.

Answers

  • MatthewNoelMatthewNoel USMember ✭✭
    edited June 2017 Accepted Answer

    I figured this out, for this purpose. I added this to the Constants:

    [Field("ALLOW_UNSUPPORTED_MAIN_THREAD_OPERATIONS", "__Internal")]
    int ALLOW_UNSUPPORTED_MAIN_THREAD_OPERATIONS { get; set; }
    

    Though the field doesn't show up in any of the .h files, this works anyway.

Sign In or Register to comment.