I'm programmatically setting up a NSButton
with a target object and I want to pass another object to the called selector.
As far as I know, I can only pass the NSButton
instance to a selector, so I'm looking for a way to store a pointer to another object inside of my NSButton
.
Is that possible or is there another way to do this?
Example:
[fooButton setAction:NSSelectorFromString(@"fooSelector:")];
[fooButton setTarget:myTargetHandler]
And now, I want to pass "myObject
" to myTargetHandler
(fooSelector:
) when fooButton
is clicked.
Have you considered simply subclassing NSButton and adding a property for this? You may even be able to achieve it with a simple category.
There's also a - (NSInteger)tag
in every UIControl - maybe that works?