“死店”警告XCode

时间:2014-03-19 10:42:27

标签: ios xcode warnings

当我分析我的项目但项目没有崩溃时,我收到一个死店警告 "值存储到'行'在初始化期间永远不会读取"。 这就是我在做的事情:

long row = [self.tableView indexPathForSelectedRow].row; // there is dead store warning
if (sqlite3_open(dbpath, &_pdd_ab_stat) == SQLITE_OK) {
    for (row = 0; row < 40; row ++) {
        NSString *querySQL = [NSString stringWithFormat:@"SELECT Max(rightCount) from paper_ab_stat WHERE biletNumber = \"%ld\"", row + 1];
        const char *query_stmt = [querySQL UTF8String];
        if (sqlite3_prepare_v2(_pdd_ab_stat, query_stmt, -1, &statement, NULL) == SQLITE_OK) {
            if (sqlite3_step(statement) == SQLITE_ROW) {
                NSNumber *arrayelement = [NSNumber numberWithInt:sqlite3_column_int(statement, 0)];
                [_biletRecords addObject:arrayelement];
            }
        }
        sqlite3_finalize(statement);
    }
}
sqlite3_close(_pdd_ab_stat);

return _biletRecords;

我该如何解决?

1 个答案:

答案 0 :(得分:4)

这是因为您未在0循环中将for重新分配给long row = [self.tableView indexPathForSelectedRow].row; if (sqlite3_open(dbpath, &_pdd_ab_stat) == SQLITE_OK) { for (row = 0; row < 40; row ++) { // Reassigned! 之前使用该值:

long row;
if (sqlite3_open(dbpath, &_pdd_ab_stat) == SQLITE_OK) {
    for (row = 0; row < 40; row ++) {

修复:

for

(虽然看起来很糟糕;你可能想在{{1}}循环中使用另一个变量)。