I've tried to go through the other questions regarding the same issue, but could not figure out an answer.
Error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell setLecture:]: unrecognized selector sent to instance 0xa85d800'
Here are relevant snippets from the code:
// UITableViewCell .h
@interface ITCourseDetailTableViewCell : UITableViewCell
@property (strong, nonatomic) ITClass * lecture;
@property (strong, nonatomic) IBOutlet UILabel *lectureCode;
- (void)setLecture:(ITClass *)lecture;
@end
// UITableViewCell .m
- (void)setLecture:(ITClass *)lecture
{
self.lecture = lecture;
self.lectureCode.text = self.lecture.classCode;
}
Here is method being called. Also, this is where the issue is happening:
// view controller .m
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString * cellIdentifier = @"ITCourseDetailTableViewCell";
ITCourseDetailTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
NSArray * nib = [[NSBundle mainBundle] loadNibNamed:cellIdentifier owner:self options:nil];
cell = [nib objectAtIndex:0];
}
ITClass * currentClass = [[[self course] courseLectures] objectAtIndex:indexPath.row];
cell.lecture = currentClass;
return cell;
}
Issue happens on this call: cell.lecture = currentClass;
The method definitely exists in the cell class. In the stack trace I can confirm that the correct cell is being instantiated and it has a _lecture
instance variable.
Relevant screenshots to confirm that the class is correctly set in the IB
Thank you very much.