我正在阅读示例代码 ListAdder,在变量之后有很多断言,或者几乎在每种方法中都使用了,例如:
self.formatter = [[[NSNumberFormatter alloc] init] autorelease];
assert(self.formatter != nil);
或者 :
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
#pragma unused(tv)
#pragma unused(indexPath)
UITableViewCell * cell;
assert(tv == self.tableView);
assert(indexPath != NULL);
assert(indexPath.section < kListAdderSectionIndexCount);
assert(indexPath.row < ((indexPath.section == kListAdderSectionIndexNumbers) ? [self.numbers count] : 1));
我想知道,这样做有什么意义?
谢谢