2009-08-21 6 views
0

L'application fonctionnera bien, puis s'écraser - littéralement une fois sur deux. Il semble que le crash nettoie la mémoire et que la course propre corrompt la mémoire. Je suppose que cela a à voir avec l'allocation de mémoire, mais je ne suis pas sûr.Mon simulateur d'iPhone se bloque chaque fois que je l'exécute

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; 

}

Répondre

0

qui est assez bizarre.

Lorsque vous dites "tous les autres", comment utilisez-vous l'application? Construire et courir? Ou juste courir?

Si elle est créée et exécutée, avez-vous des phases de construction personnalisées qui copient des fichiers ou effectuent un traitement personnalisé? La traçabilité indique que l'unité se bloque pendant le chargement du NIB, en particulier lors de la configuration d'une prise. Y a-t-il une chance que vous ayez le mauvais objet en tant que propriétaire du fichier? Peut-être un chemin de code différent en fonction de ce qui est lu depuis le système de fichiers au lancement de l'application?

+0

générer et exécuter toujours – Bryan

+0

Je ne fais aucun traitement personnalisé. Je charge simplement un fichier texte avec quelques données. Rien de fou en cours. Merci pour votre réponse bbum – Bryan

+0

postez votre méthode cellForRowAtIndexPath – Jordan