Can I use array for IBOutlet?

Discussion in 'iPhone/iPad Programming' started by mikezang, Jul 18, 2010.

  1. macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #1
    I have a table view with more than ten cells in row, it is not easy to set data as below
    Code:
    //  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?
    Code:
    //  CustomCell.h
    #import <UIKit/UIKit.h>
    @interface CustomCell : UITableViewCell {
    	UILabel *label[10];
    }
    @property (nonatomic, retain) IBOutlet UILabel *label[10];
    @end
     
  2. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    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.
     
  3. thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #3
    That is too sad:(
     

Share This Page