Bonjour à tous,
A la fois nouveau dans le monde des développeurs pour Iphone, je rencontre un petit soucis qui doit être tout bête j'imagine, mais que je n'ai pas trouvé
je travaille sur une UITableView, qui va charger ses éléments sur SQLite (Chargement des données OK et testé)
Au moment de l'insertion du texte de la cellule dans cellForRowAtIndexPath les valeurs de mon MSMutableArray (nommé listStation) sont comme "inaccessible".... une idée?(J'ai commenté le code, voir //Ici sa crash)
Mon .h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #import "Station.h" #import "SQLManager.h" @interface SecondViewController : UIViewController { (...) //Data NSMutableArray *listStation; NSMutableArray *listStationSearched; Station *stationSearched; SQLManager *sqlManager; } (...) (...) @property(nonatomic,retain) NSMutableArray *listStation; @property(nonatomic,retain) NSMutableArray *listStationSearched;
Mon .m
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79 @synthesize... //Correctement // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { // Custom font, color [super viewDidLoad]; stationSearched = nil; //Initialize the array. listStation = [[NSMutableArray alloc]init]; listStationSearched = [[NSMutableArray alloc]init]; // initialisation de la BDD sqlManager = [[SQLManager alloc] initDatabase]; [sqlManager checkAndCreateDatabase]; [sqlManager readStationTableFromDatabase]; NSInteger i = 0; //Retourne 4 (nbLigne dans la table Station sur SQLite) NSLog(@"Data Sql:%d",[sqlManager.stationTable count]); while (i < [sqlManager.stationTable count]) { Station *oneStation = (Station *)[sqlManager.stationTable objectAtIndex:i]; [listStation addObject:oneStation]; //NSLog(@"%@",[oneStation nameStation]); i++; //[oneStation release]; } //Retourne 4 (Contient les objets de la BDD) NSLog(@"Data App:%d",[listStation count]); //Retourne le nom de la station 1 (Fonctionne) NSLog(@"%@",[[listStation objectAtIndex:1]nameStation]); boolSearching = NO; boolLetUserSelectRow = (BOOL *)YES; //[sqlManager release]; //[tramArray release]; //[busArray release]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; } if(boolSearching){ if([listStationSearched count] > 0){ /*[cell.textLabel setText:[[listStationSearched objectAtIndex:indexPath.row] nameStation]]; [cell.detailTextLabel setText:[NSString stringWithFormat:@"%d", [[listStationSearched objectAtIndex:indexPath.row] numberStation]]];*/ } }else { if([listStation count] > 0){ //Ici sa crash, il n'arrive pas a transmettre l'objet :/ NSLog(@"%@",[[listStation objectAtIndex:indexPath.row] nameStation]); NSLog(@"%d",[[listStation objectAtIndex:indexPath.row] numberStation]); //[cell.textLabel setText:[[listStation objectAtIndex:indexPath.row] nameStation]]; //[cell.detailTextLabel setText:[NSString stringWithFormat:@"%d", [[listStation objectAtIndex:indexPath.row] numberStation]]]; } } return cell; } @end
Partager