开发者

actual difference between - (IBAction)pushClear:(id)sender and - (IBAction)pushClear:(NSButton)sender

开发者 https://www.devze.com 2023-04-07 16:35 出处:网络
When I link buttons to the source code (.h file in this case) and select NSButton as type it Xcode will write:

When I link buttons to the source code (.h file in this case) and select NSButton as type it Xcode will write:

- (IBAction)pushClear:(id)sender;

as far as I understand it should be

- (IBAction)pushClear:(NSButton)sender;

am I right, or just somewhat confused? If I link s.th. from within the iOS Interface Builder, everything seems to do what it should.

so will I have to fix these things by hand? Or is it ok the way it is (in the end, every things working fine. Just don't want to step into problems down the road.

EDIT:

Is there some sort of performanc开发者_开发问答e issue by just using?

- (IBAction)pushClear:(id)sender; 


You can set type like this:

- (IBAction)pushClear:(NSButton *)sender;

if you are sure, that only NSButton objects will send this actions.

If you are not sure, than you may leave:

- (IBAction)pushClear:(id)sender;

and inside of this method check that sender is kind of class NSButton.

0

精彩评论

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

关注公众号