PDA

View Full Version : Can I use array for IBOutlet?




mikezang
Jul 18, 2010, 11:41 AM
I have a table view with more than ten cells in row, it is not easy to set data as below

// CustomCell.h
#import <UIKit/UIKit.h>
@interface CustomCell : UITableViewCell {
UILabel *labelStartDate;
UILabel *labelEndDate;
UILabel *labelTradeType;
UILabel *labelAccount;
UILabel *labelCode;
UILabel *labelName;
UILabel *labelAmount;
UILabel *labelStartPrice;
UILabel *labelEndPrice;
UILabel *labelValue;
UILabel *labelProfitLoss;
UILabel *labelProfitLossRate;
}
@property (nonatomic, retain) IBOutlet UILabel *labelStartDate;
@property (nonatomic, retain) IBOutlet UILabel *labelEndDate;
@property (nonatomic, retain) IBOutlet UILabel *labelTradeType;
@property (nonatomic, retain) IBOutlet UILabel *labelAccount;
@property (nonatomic, retain) IBOutlet UILabel *labelCode;
@property (nonatomic, retain) IBOutlet UILabel *labelName;
@property (nonatomic, retain) IBOutlet UILabel *labelAmount;
@property (nonatomic, retain) IBOutlet UILabel *labelStartPrice;
@property (nonatomic, retain) IBOutlet UILabel *labelEndPrice;
@property (nonatomic, retain) IBOutlet UILabel *labelValue;
@property (nonatomic, retain) IBOutlet UILabel *labelProfitLoss;
@property (nonatomic, retain) IBOutlet UILabel *labelProfitLossRate;
@end

Can I use as below?

// CustomCell.h
#import <UIKit/UIKit.h>
@interface CustomCell : UITableViewCell {
UILabel *label[10];
}
@property (nonatomic, retain) IBOutlet UILabel *label[10];
@end



PhoneyDeveloper
Jul 18, 2010, 12:01 PM
No that won't work. Amusing idea though.

You could set tags for these views in IB and recover the labels with viewWithTag: if you find that more convenient.

mikezang
Jul 18, 2010, 12:09 PM
That is too sad:(