Это в UIViewController
. Я хочу запустить reloadData
на моем столе, но это не сработает.Почему я не могу запустить reloadData?
Во-первых, я звоню fromGenre:
с другого взгляда. Я начинаю NSURLConnection
. Затем он вызывает connectionDidFinishLoading:
. Затем doParse:
. После этого в этой функции я хочу позвонить reloadData
. Но это не работает.
- (void)viewDidLoad{
[super viewDidLoad];
}
//Parse function
-(void)doParse{
NSString *jsonString = [[NSString alloc]initWithData:result encoding:NSUTF8StringEncoding];
data2=[[[[jsonString JSONValue]] objectForKey:@"feed"] objectForKey:@"entry"];
trackGenre = [[NSMutableArray alloc]init];
for (NSDictionary *dic in data2) {
NSString *artistName = [[dic objectForKey:@"im:artist"]objectForKey:@"label"];
NSMutableDictionary *dicData = [NSMutableDictionary dictionary];
[dicData setValue:artistName forKey:@"artist"];
[trackGenre addObject:dicData];
}
**//[self.aTableView reloadData];
/*
[ self.aTableView performSelectorOnMainThread:@selector(reloadTableView)
withObject:nil
waitUntilDone:YES
];*/
[self performSelectorOnMainThread:@selector(reloadTableView) withObject:nil waitUntilDone:YES];
//[self reloadTableView];**
}
-(void)reloadTableView{
[[[self view] aTableView] reloadData];
NSLog(@"do reload");
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
//[self doParse];
[self performSelectorOnMainThread:@selector(doParse) withObject:nil waitUntilDone:YES];
}
-(void)fromGenre:(NSURLRequest *)urlRequest{
NSLog(@"urlRequest:%@",urlRequest);
aConnection = [NSURLConnection connectionWithRequest:urlRequest delegate:self];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return trackGenre ? [trackGenre count]:100;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"second_VC_Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.textLabel.text = [[trackGenre objectAtIndex:indexPath.row]objectForKey:@"track"];
return cell;
}
@end
Ваш вопрос действительно неясно ... Можете ли вы объяснить лучше, что ваш проблема есть? – Saphrosit
Моя проблема в том, что мне нужно сделать, чтобы перезагрузить DataView. Это все. –
Не должен ли 'reloadData' вызывать' self.aTableView', а не '[[self view] aTableView]'? Итак, '[self.aTableView reloadData]' – darvids0n