iはサンプルコードListAdderを通して読んでいた、そして右の変数の後にアサート多くの、またはほとんどすべての方法に使用される、例えば、がある(そしてなぜ何度使用して):なぜプロジェクトで 'assert'を使うのですか?
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));
私は不思議に思っていましたが、何がポイントですか?
おかげ
私はObjective Cについては分かりませんが、他の言語ではコンパイル時には無効にすることができ、ライブシステムの速度を落とすことはありませんが、テストやステージング中にバグ検出に使用できます。 – corsiKa