开发者

How to add parameter in the addTarget's selector?

开发者 https://www.devze.com 2023-01-22 14:14 出处:网络
Say I have a function like this: -(void)activateDict:(NSNumber*)dictID{ } Then I add a action for my button:

Say I have a function like this:

-(void)activateDict:(NSNumber*)dictID{

}

Then I add a action for my button:

 [aBtn addTarget:self action:@selector(activateDict) forControlEvents:UIControlEventTouchUpInside];

There is a parameter in the act开发者_开发百科ivateDict function, which is (NSNumber*)dictID, so when I add the action to button, how can I add the parameter to the function? like: action:@selector(activateDict:theDictID).


You would normally define activateDict as activateDict: (id) sender and then make dictID an ivar of sender.

0

精彩评论

暂无评论...
验证码 换一张
取 消