Skip to content

Instantly share code, notes, and snippets.

@tobiastom
Forked from jeena/gist:475862
Created July 14, 2010 19:09
Show Gist options
  • Save tobiastom/475878 to your computer and use it in GitHub Desktop.
Save tobiastom/475878 to your computer and use it in GitHub Desktop.
@interface SquaceMenuItem : UIMenuItem {
SquaceMLAction *squaceAction;
}
@property (nonatomic, retain) SquaceMLAction *squaceAction;
@end;
@implementation SquaceMenuItem
@synthesize squaceAction;
@end
- (void)openMoreAfterDelay:(id)sender {
UIMenuController *menuController = [UIMenuController sharedMenuController];
[self becomeFirstResponder];
NSMutableArray *menuItems = [[NSMutableArray alloc] init];
for (SquaceMLAction *action in [[dataSource.squaceML.squaregrid.squares objectAtIndex:activeIndex] actions]) {
SquaceMenuItem *item = [[SquaceMenuItem alloc] initWithTitle:action.text action:didSelectMenuItem:)];
item.squaceAction = action;
[menuItems addObject:item];
[item release];
}
menuController.menuItems = menuItems;
[menuItems release];
[menuController update];
[menuController setMenuVisible:YES animated:YES];
}
- (IBAction)didSelectMenuItem:(SquaceMenuItem *)menuItem {
NSLog(@"Do frakking magic with: %@", menuItem.squaceAction);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment