Я загружаю данные динамически из API, используя UISearchBar
и пытаюсь отобразить их, используя что-то вроде этого:
- (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];
Мой UITableViewController
код настроен для чтения из self.data, который изначально представляет собой NSArray
из @""
элементов, как таковых:
- (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;
}
Все, что я получаю, когда я делаю это:
(GDB) продолжить
2010-02-26 18: 43: 32.515 iSave [11690: 207] (
"Toshiba Satellite L505-GS5037 TruBrite 15,6-дюймовый ноутбук (черный)",
«Dell Inspiron 11 11,6-дюймовый черный ноутбук Obsidian (Windows 7 Premium)»,
«10,1-дюймовый черный нетбук ASUS Eee PC Seashell 1005PE-MU17-BK - до 11 часов автономной работы»,
"SwissGear Computer Backpack (Красный)",
"Разъёмный компьютерный комплект Belkin, 36 предметов, с чехлом (черный)",
"Compaq EVO N610C",
"Belkin F8E062 Набор из 55 компьютерных инструментов с черным корпусом (размагниченные инструменты)",
«Черный нетбук ASUS Eee PC Seashell 1005PE-PU17-BK с диагональю 10,1 дюйма - до 14 часов автономной работы»,
«Мультимедийная акустическая система« подключи и играй »Harman Kardon SoundSticks II 2.1»,
«ION Audio VCR 2 ПК USB VHS видео в компьютер конвертер»
)
(GDB) продолжить
Программа получила сигнал: «EXC_BAD_ACCESS».
(ГБД)
Есть идеи? Похоже, что NSArray
заполняется правильно, затем происходит сбой в / после вызова reloadData (точки останова подтверждают это, но не могут определить, где что-то идет не так)
РЕДАКТИРОВАТЬ : я заменил NSLog()
на перечисление
for ( NSString *elem in self.data )
NSLog(elem);
И все равно падает. Мне удалось вывести из него логи: http://pastebin.com/NDVKLsJC
Когда я полностью удаляю NSLog()
, он не падает, но UITableView
тоже не обновляется.