Skip to content

Instantly share code, notes, and snippets.

@r-plus
Created October 9, 2010 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r-plus/618365 to your computer and use it in GitHub Desktop.
Save r-plus/618365 to your computer and use it in GitHub Desktop.
//ActionMenu Daijirin Plugin.
//2010/10/10 r_plus create.
//version 0.1-1
#import <UIKit/UIKit.h>
#import "ActionMenu.h"
@implementation UIResponder (Daijirin)
- (void)doDaijirin:(id)sender
{
NSMutableString *string;
NSString *text;
NSURL *theURL;
static NSString * const DAIJIRIN = @"mkdaijirin://jp.monokakido.DAIJIRIN/search";
NSString *selection = [self selectedTextualRepresentation];
string = [[NSMutableString alloc] initWithString:DAIJIRIN];
text = @"";
if ([selection length] > 0) {
text = [selection stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
}
//next futuer
//[string appendFormat:@"?text=%@&option=%d&srcname=%@&src=%@", text, __MKDSearchExactMatch, srcname, src];
[string appendFormat:@"?text=%@",text];
theURL = [[NSURL alloc] initWithString:string];
[[UIApplication sharedApplication] openURL:theURL];
[theURL release];
[string release];
}
- (BOOL)canDoDaijirin:(id)sender
{
return [self respondsToSelector:@selector(insertText:)];
//return YES;
}
+ (void)load
{
id<AMMenuItem> m = [[UIMenuController sharedMenuController] registerAction:@selector(doDaijirin:) title:@"Daijirin" canPerform:@selector(canDoDaijirin:)];
//m.image = [[UIImage alloc] initWithContentsOfFile:@"/Library/ActionMenu/Plugins/Daijirin.png"];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment