Call selectors from your code. Create own buttons

by alex 26. May 2010 08:32

///////////////////BUTON

//-- button.h file

@interface MyButton : NSObject {

id receiver;

SEL selector;

}

 

 

//-- button.m file

-(void)addTarget:(id)target action:(SEL)action{

receiver = target;

selector =  action;

}

 

-(void)touch{

if (receiver) {

[receiver performSelector:selector];

}

}

 

//////////////////RECEIVER 

//-- receiver.m file

 

...

MyButton *mybutton = [[MyButton alloc] init];

[mybutton addTarget:self action:@selector(actionMethod)];

...

 

-(void)actionMethod{

//some code

}

Currently rated 4.2 by 5 people

  • Currently 4.2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen