0

アプリは正常に実行され、その後クラッシュします-文字通り1回おきに。クラッシュによってメモリがクリーンアップされ、クリーンランによってメモリが破損したようです。

メモリ割り当てに関係していると思いますが、よくわかりません。

代替テキスト

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *MyIdentifier = @"MyStateCell";
static NSString *MyNib = @"StateCell";

StateCell *cell = (StateCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];

if (cell == nil) {
    UIViewController *c = [[UIViewController alloc] initWithNibName:MyNib bundle:nil];
    cell = (StateCell *)c.view;

    [c autorelease];
}

// Configure the cell.
NSString *cellAnswerName = [[NSString alloc] initWithFormat:@""];
cellAnswerName = [theQuizArray objectAtIndex:indexPath.row];
int theStatusCode = [[theResultArray objectAtIndex:indexPath.row] intValue];

NSString *statusString;
NSString *pointsWon;

if(theStatusCode == 0){
    statusString = [NSString stringWithFormat:@""];
    pointsWon = [NSString stringWithFormat:@""];
}else if( theStatusCode == 12){
    statusString = [NSString stringWithFormat:@"Wrong"];
    pointsWon = [NSString stringWithFormat:@"0"];
}else if(theStatusCode == 11){
    statusString = [NSString stringWithFormat:@"Out of time"];
    pointsWon = [NSString stringWithFormat:@"0"];
}else{
    int elapsedTime = 10 - theStatusCode;
    int pointsWonInt = 10 * theStatusCode;
    pointsWon = [NSString stringWithFormat:@"%i", pointsWonInt];
    if(elapsedTime == 1){
        statusString = [NSString stringWithFormat:@"%i second", elapsedTime];
    }else{
        statusString = [NSString stringWithFormat:@"%i seconds", elapsedTime];
    }
}

NSString *imagePath = [[@"State_" stringByAppendingString:cellAnswerName] stringByAppendingString:@".png"];
UIImage *image = [UIImage imageNamed:imagePath];

[[cell stateImage] setImage:image];
[[cell stateName] setText:cellAnswerName];
[[cell stateResult] setText:statusString];
[[cell statePoints] setText:pointsWon];


if([statusString isEqualToString:@"Wrong"])
[[cell stateResult] setTextColor:[UIColor redColor]];


return cell;

}

4

1 に答える 1

0

それはかなり奇妙です。

「1回おきに実行する」と言うとき、アプリはどのように実行していますか?ビルドして実行しますか?または単に実行しますか?

ビルドして実行する場合、ファイルをコピーしたり、カスタム処理を行ったりするカスタムビルドフェーズはありますか?

バックトレースは、NIBの読み込み中、特にコンセントを設定しているときに、がクラッシュしていることを示しています。ファイルの所有者として間違ったオブジェクトを持っている可能性はありますか?アプリの起動時にファイルシステムから読み取られる内容に応じて、コードパスが異なる可能性がありますか?

于 2009-08-21T23:24:11.057 に答える