2009-08-21 16 views
0

アプリはうまく動作し、その後はクラッシュする。クラッシュがメモリをクリーンアップし、クリーンな実行がメモリを破壊するようです。私のiPhoneシミュレーターはいつもクラッシュする私はそれを実行する

私はそれがメモリ割り当てと関係があると思いますが、わかりません。かなり奇妙である

alt text

- (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; 

}

答えて

0

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

ビルドして実行している場合は、ファイルをコピーするカスタムの作成フェーズがありますか?

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

+0

常に実行します – Bryan

+0

私はカスタム処理を行っていません。テキストファイルにデータをロードするだけです。何も狂っていることはありません。あなたの答えをお返事いただきありがとうございます。 – Bryan

+0

cellForRowAtIndexPathメソッド – Jordan

関連する問題