在运行单元测试时创建UILabel时,会导致 EXC_BREAKPOINT(代码= EXC_i386_BPT,子代码0x0)
我做错了什么?
- (void)setLabelCount:(NSUInteger)labelCount {
_labelCount = labelCount;
NSMutableArray *labels = [[NSMutableArray alloc] init];
for (int idx=0; idx<self.labelCount; idx++) {
UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectZero]; // <---
lbl.backgroundColor = [UIColor clearColor];
[labels addObject:lbl];
[self.dataView addSubview:lbl];
}
self.labels = labels;
[self updateContents];
}
以下是调用此代码的单元测试
- (void)setUp {
cell = [[LDPChartCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ChartCell"];
cell.labelCount = 10; // <---
}
- (void)tearDown {
cell = nil;
}
- (void)testThatReuseIdentifierIsSet {
STAssertEqualObjects(cell.reuseIdentifier, @"ChartCell", @"");
}