We set the architecture to be armv7 and arm64 (64-bit). Then we include Theos' common.mk file, and after that we define the properties for our library project.

AMExample.h

We will first create our header file which will not have more than the category interface:

#import "ActionMenu.h" //import the Action Menu Header@interfaceUIResponder(MyAwesomePlugin)//create our Category-(BOOL)canPerformAction;//(we will check here if the selected text is longer than 0 characters)-(void)performMyAction;//this method will do the actual 'work' of our Plugin@end

AMExample.m

We are going to implement the methods and then our category in the .m implementation file.

First we include our header file and write our @implementation section:

Now we have to implement the canPerformAction and performMyAction method. The canPerformAction checks for the length of the selected text and checks wether it is 0 or higher. It can only perform (return TRUE) if the selected text is longer than 0 characters.

Now we have to implement the canPerformAction and performMyAction method to complete this plugin:

-(BOOL)canPerformAction{//returns TRUE if the selected text is longer than 0 charactersreturn[[selfselectedTextualRepresentation]length]>0;}

And in our performMyAction method we show an UIAlertView:

-(void)performMyAction{//get the selected textNSString*selection=[selfselectedTextualRepresentation];UIAlertView*av=[[UIAlertViewalloc]initWithTitle:@"Selected Text"message:selectiondelegate:nilcancelButtonTitle:@"Okay"otherButtonTitles:nil];[avshow];//shows the alert[avrelease];//releases the object to avoid memory leaks}

To sum it up, +(void)load registers our Action Menu Item to be shown in the UIMenuController, - (BOOL)canPerformAction checks if there is any selected text, and - (void)performMyAction will run our code when the menu item is selected.

This is everything you need to know for your first Action Menu Plugin. All you need to do is change the actions that take place in the performMyAction method and you can customize your plugin.