Je chargement des données dynamiquement à partir d'une API à l'aide d'un UISearchBar
et d'essayer de l'afficher, en utilisant quelque chose comme ceci:EXC_BAD_ACCESS sur reloadData
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
[searchBar resignFirstResponder];
NSLog(@"Search Text: %@",[searchBar text]);
[self startSearchingWithText:[searchBar text]];
}
- (void) startSearchingWithText:(NSString *)text {
...
// Go through the list of services and set up a query for the search term
QueryServiceManager *manager = [[QueryServiceManager alloc] initWithServices: services];
// Set up the query
if (![manager addKeyword: text])
NSLog(@"PROBLEM!");
// Execute the query and store the titles in an array
self.data = [[manager makeQuery] copy]; // Returns a NSArray
NSLog(@"%@",self.data);
// Add the items to the tableView
[self.tableView reloadData];
Mon code UITableViewController
est configuré pour lire self.data, qui est d'abord un NSArray
de @""
éléments, tels que:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
[self.data count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Set up the cell...
cell.textLabel.text = [self.data objectAtIndex:indexPath.row];
return cell;
}
Tout ce que je reçois quand je fais est:
(gdb) continuer 2010-02-26 18: 43: 32.515 iSave [11690: 207] ( "Ordinateur portable Toshiba Satellite L505-GS5037 TruBrite 15,6" (noir) ", " Dell Inspiron 11 Obsidian 11,6 pouces Ordinateur portable noir (Windows 7 Premium) ", " ASUS Eee PC Netbook 1005PE-MU17-BK Netbook noir 10,1 pouces - Jusqu'à 11 heures d'autonomie ", " SwissGear Computer Backpack (Red) ", " Belkin 36- Trousse d'outils informatiques dématérialisés avec étui (noir) ", " Compaq EVO N610C ", " Trousse d'outils informatiques 55 pièces Belkin F8E062 avec boîtier noir (outils démagnétisés) ", " Coque ASUS Eee PC 1005PE-PU17-BK 10.1 Noir Netbook -inch - Jusqu'à 14 heures de la vie de la batterie " " Harman Kardon SoundSticks II 2.1 Système de haut-parleurs multimédias Plug and Play ", " ION Audio VCR 2 Convertisseur vidéo USB vers ordinateur VHS " ) (gdb) continuer Programme reçu signal:" EXC_BAD_ACCESS ". (gdb)
Des idées? On dirait que le NSArray
est en cours à jour correctement, alors les choses ne parviennent pas à/après l'appel reloadData (points d'arrêt confirment, mais ne peut pas isoler où les choses vont mal)
EDIT: J'ai remplacé le NSLog()
avec énumération
for (NSString *elem in self.data)
NSLog(elem);
Et il se bloque toujours. J'ai réussi à coaxer un journal hors de celui-ci: http://pastebin.com/NDVKLsJC
Lorsque je supprime le NSLog()
entièrement, il ne se bloque pas, mais le UITableView
ne met pas à jour non plus.
où vous appelez reloadData? – nickthedude
oh je ne vois rien là-bas – nickthedude
Sous la commande NSLog() ci-dessus. Cette fonction est appelée automatiquement lorsque le bouton "Rechercher" est touché. Post édité pour afficher la définition complète. –