I am trying to add a button programatically in a way that upon pressing it, a certain object is being passed. I keep on getting "unrecognized selector sent" exception. Can you suggest whats wrong with the code:
// allocate the details button's action
SEL selector = @selector(showPropertyDetails:forProperty:);
NSMethodSignature *signature = [[self class] instanceMethodSignatureForSelector:selector];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:selector];
//The invocation object must retain its arguments
[property retain];
//Set the arguments
[invocation setTarget:self];
[invocation setArgument:&property atIndex:3];
[(UIButton*)[myView viewWithTag:15] addTarget:self action:@selector(selector) forControlEvents:UIControlEventTouchDown];
and further down, the method in the same class looks like:
-(void) showPropertyDetails:(id)something forProperty:(Property *)property {
int i=0;
}