objective-ccocoasecurity-frameworksfauthorizationpluginview

Triggering callback without pressing the button in Cocoa


I need to be able to start the authentication process in this sample without pressing the button provided by default.

The action I want to run is the -(void)buttonPressed method, but if I try to invoke it manually the plugin crashes. It's invoked automatically by pressing that button but it would be nice to be able to just press enter.


Solution

  • This should all be obvious after a single glance in the plugin source code you linked!

    While it shouldn't crash (after a quick look into the class code), you probably do not supply the appropriate sender when sending buttonPressed: from your code. The method is defined as

    - (void)buttonPressed:(SFButtonType)inButtonType
    

    Which clearly shows the button that was pressed is given as sender. So in your code when calling buttonPressed: do for example like:

    ["referenceRToClass" buttonPressed:SFButtonTypeOK];