How to call private API from Monotouch?

My knowledge at P/InvokeMonotouch is pretty awful, and I want to call the iOS private API for UITextView(in particular setContentToHTMLString), and I'm not sure where to start from there.

If anyone could tell me how this is done (or even where to start!) That would be brilliant.

Just note that this is for the personal project that I am doing, mainly to expand my knowledge. The chances of getting this application in the application store are very thin, so it does not fall under the rules of the App Store / Apple's ability to change it.

change

Is this just a use case Selector?

+3
source share
2 answers

The easiest way to call it with a selector, for example:

Selector s = new Selector("myPrivateAPIMethodName");
MyObjectToCallTheMethodOn.PerformSelector(s, parameterOfTheObject, 0);

, . Apple API , , AppStore - API, , .

+2

.net, .

:

            object oToInvoke;

        //Get the type of object
        Type t = typeof( oToInvoke );

        //Invoke 'PrivateMethodName'
        return t.InvokeMember( "PrivateMethodName",
                          System.Reflection.BindingFlags.NonPublic
                        | System.Reflection.BindingFlags.Instance
                        | System.Reflection.BindingFlags.InvokeMethod
                        , null
                        , oToInvoke
                        , null );

, . InvokeMember

Thats in the System.Reflection Namespace

, !

0

Source: https://habr.com/ru/post/1784932/


All Articles