开发者

managing IB objects without iboutlets

开发者 https://www.devze.com 2023-01-03 08:19 出处:网络
i have got 24 buttons in my project.I need to manage them but I don\'t want to get my MainViewController polluted by 24 declarations of pointers, properties & synthesizes.

i have got 24 buttons in my project.I need to manage them but I don't want to get my MainViewController polluted by 24 declarations of pointers, properties & synthesizes.

i was thinking about using buttonPushed functions and do it like:

> -(IBAction)buttonPushed:(id)sender{

> UIbutton *button=sender;

>[buttons addObjectAtIndex:[sender tag]];

>}

my question is:is sender a pointer to the IBObject?

edit开发者_StackOverflow社区:

I need to get a pointer to an object in interface builder which has not been clicked (so any (id)sender sent yet), what to do?


Yes, the sender parameter will contain your button that was pushed. This design pattern was designed exactly for this, the case you have one method for multiple actions


Yes, sender is the IBObject that sent the buttonPushed message. You can ask the sender (the button) for identifying information (such as the label) to decide what action to take.

0

精彩评论

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