tableView で使用するカスタム TableView セルがあります。そのメソッドの一部を tableViewController に委譲する必要があると判断しました。
//Custom tableview cell
typedef enum {
kButtonSelected,
kButtonNormal
} ButtonState;
// Classes using this custom cell must implement these methods
@protocol CustomTableViewCellDelegate <NSObject>
@required
- (void) storeButtonState:(ButtonState)state forButton:(UIButton *)sender;
- (void) restoreButtonState:(UIButton *)tagLectureButton;
@end
@interface CustomTableViewCell : UITableViewCell
// Delegate
@property (assign) id <CustomTableViewCellDelegate> delegate;
@property (weak, nonatomic) IBOutlet UILabel *mainLabel;
@property (weak, nonatomic) IBOutlet UILabel *numberLabel;
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *spinner;
@property (weak, nonatomic) IBOutlet UIButton *tagLectureButton;
次に、TableView をデリゲートとして設定し、メソッドを実装します。ここまでは順調ですね
@interface LecturesSubTVC : LecturesTVC <CustomTableViewCellDelegate>
しかし、設定するインスタンス変数がありません(self.CustomTableViewCell.delegate = self;)
すべてのセルは、次のようなメソッド内で割り当てられます。
CustomTableViewCell *cell = (CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
デリゲートされたメソッドが呼び出されるように、セルをデリゲートとして設定するにはどうすればよいですか?