No, no, no.
@property (nonatomic,strong) NSArray *arrayOfDays;
Now get rid of all those day objects and fill that self.arrayOfDays
with whatever all those individual day objects are...
Then...
for(int i=0; i<[self.arrayOfDays count]; ++i) {
[[self.arrayOfDays objectAtIndex:i] setDelegate: self];
}
Or even better, if all those objects are of the same type (I'll assume they're of type Day
), we can do:
for(Day *day in self.arrayOfDays) {
day.delegate = self;
}
Best (per Daij-Dan's comment):
[self.arrayOfDays setValue:self forKeyPath:@"delegate"];
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…