Possible Duplicate:
Handling multiple UISwitch controls in a table view without using tag property
Well i want to ask how can i configure 7 UISwitches on one UIview? I place the switches with interface builder and then i want to manage them through code. What is the best way of managing this. Here is my .h so far
#import <UIKit/UIKit.h>
@interface searchEditViewController : UIViewController{
UISwitch *switchOne;
UISwitch *switchTwo;
UISwitch *switchFor;
UISwitch *switchFive;
UISwitch *switchSix;
UISwitch *switchSeven;
}
@property(nonatomic,retain)UISwitch *switchOne;
@property(nonatomic,retain)UISwitch *switchTwo;
@property(nonatomic,retain)UISwitch *switchThree;
@property(nonatomic,retain)UISwitch *switchFour;
@property(nonatomic,retain)UISwitch *switchFive;
@property(nonatomic,retain)UISwitch *switchSix;
@property(nonatomic,retain)UISwitch *switchSeven;
-(IBAction)toggleButtonPressed:(id)sender;
@end
I want to make one action method toggleButtonPressed that will take care the seven of them
Create one action for all
UISwitchobjects (I guess this istoggleButtonPressed). In this method now you can know which UISwitch was triggered:Edit. You can set
tagproperty to some value (from 1 to 7) and changeif-statementtoswitch-case.