开发者

Why it doesn't recognise my selector?

开发者 https://www.devze.com 2023-03-16 13:37 出处:网络
I want to change the action of an UIButton and it gives me an exception when touching the button. [grabRedeem removeTarget:self ac开发者_C百科tion:@selector(grabbOffer:) forControlEvents:UIControlEve

I want to change the action of an UIButton and it gives me an exception when touching the button.

[grabRedeem removeTarget:self ac开发者_C百科tion:@selector(grabbOffer:) forControlEvents:UIControlEventTouchUpInside];
[grabRedeem addTarget:self action:@selector(redeemOffer:) forControlEvents:UIControlEventTouchUpInside];

grabbOffer and redeemOffer are IBActions that are implemented with no parameters.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DetailViewController grabbOffer:]: unrecognized selector sent to instance 0x1e8bf0'

What could be the reason?


Have you tried to remove the colon:

[grabRedeem removeTarget:self action:@selector(grabbOffer) forControlEvents:UIControlEventTouchUpInside];
[grabRedeem addTarget:self action:@selector(redeemOffer) forControlEvents:UIControlEventTouchUpInside];

you use the semicolon when you want to use a parameter:

-(void)grabbOffer:(id)sender;


If you function implemented with no parameters use: @selector(grabbOffer) instead @selector(grabbOffer:)

0

精彩评论

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