問題があります。
私は CityViewController.m を持っています
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
TheatreController *tmpTheatreController = [storyboard instantiateViewControllerWithIdentifier:@"TheatreController"];
NSString *cityView = [[self.arrayCity objectAtIndex:indexPath.row] valueForKey:@"idCity"];
tmpTheatreController.cityView = cityView;
//[self.navigationController pushViewController:tmpTheatreController animated:YES];
[tmpTheatreController.tableView reloadData];
[self.delegate citiesViewControllerCancel:self];
}
都市を選択すると、TheatreController.m の「idCity」が正しく渡されます
...
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"SelectCity"])
{
UINavigationController *nc = segue.destinationViewController;
CityViewController *mvc = [[nc viewControllers] objectAtIndex:0];
mvc.delegate = self;
}
}
...
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *webUrl = @"http://localhost:3000/theatres?city=";
webUrl = [webUrl stringByAppendingFormat:@"%@", cityView];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:webUrl]];
[self performSelectorOnMainThread:@selector(fetchedData:)
withObject:data waitUntilDone:YES]; });
}
- (void)fetchedData:(NSData *)responseData {
NSArray* json = [NSJSONSerialization
JSONObjectWithData:responseData
options:kNilOptions error:nil];
NSMutableArray *theatreTMP = [[NSMutableArray alloc] initWithCapacity:[json count]];
int i = 0;
for (id object in [json valueForKeyPath:@"response.name"]) {
Theatres *t = [[Theatres alloc] init];
NSLog(@"JSON: %@", [[json valueForKeyPath:@"response.name"] objectAtIndex:i]);
t.theatre = [[json valueForKeyPath:@"response.name"] objectAtIndex:i];
t.idTheatre = [[json valueForKeyPath:@"response.id"] objectAtIndex:i];
[theatreTMP addObject:t];
i++;
}
self.arrayTheatre = [theatreTMP copy];
[self.tableView reloadData];
}
サーバーの応答は正しく、すべてのパラメーターは正しいですが、tableView メインの reloadData に問題があります![ここに画像の説明を入力][1]。更新テーブルが表示されません。
助けて ありがとう