В предыдущем контроллере просмотра я отобразил несколько названий рецептов. после щелчка на конкретной ячейке, она переходит к следующему представлению и призыв к серверу как следующее:Почему tableview не отображает мой массив словарей?
::
::
[manager POST:Loginurl parameters:params progress:nil success:^(NSURLSessionTask *task, id responseObject) {
NSLog(@"Response from view Prescription server : %@", [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]);
NSArray *ResponseArray = [NSJSONSerialization JSONObjectWithData: responseObject options: kNilOptions error: nil];
if (ResponseArray.count >0)
{
self.menuItems = [[NSMutableArray alloc]initWithArray:ResponseArray];
}
NSLog(@"menu_itemes: %@",_menuItems);
я получил следующий ответ в menu_items:
menu_itemes: (
{
bp = "000/000";
dateTime = "05/12/2016 01:02:59 PM";
doc = {
"email_id" = "[email protected]";
exception = 0;
gender = Male;
id = 0;
"mobile_no" = 8055621745;
name = Batra;
"profile_id" = 0;
qualification = "MD(Doctor)";
"reg_id" = 157;
salutation = Mr;
"wellness_id" = 251215782521;
};
"follow_up" = 17;
id = 37;
medicine = (
"Syrup,Decold Total,20,0-0-1,Before Meal,1",
"Injection,Insulin,1,0-0-1,Before Meal,1",
no,
no,
no,
no,
no,
no,
no,
no
);
patient = {
"email_id" = "[email protected]";
exception = 0;
gender = Male;
id = 0;
"mobile_no" = 8055621745;
name = Rohit;
"profile_id" = 0;
qualification = "";
"reg_id" = 150;
salutation = Mr;
"wellness_id" = 290119935030;
};
weight = 000;
}
)
Я хочу, чтобы отобразить эти данные как следующее:
Для этого я попытался, как следующее:
Для этого я взял UITableView
.
Я взял 1 статический пользовательский элемент для этого.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
// return self.menuItems.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *content = [self.menuItems objectAtIndex:0];
NSLog(@"content = %@",content);
ViewPrescriptionTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"PatientDetail" forIndexPath:indexPath];
[cell.datetime setText:[content valueForKey:@"dateTime"]];
[cell.doctorname setText:[[content objectForKey:@"doc"]valueForKey:@"name"]];
return cell;
}
Но ничего не отображается.
я получил null
в
NSLog(@"content = %@",content);
когда я даю numberOfRowsInSection
является 1, то cellForRow
называется ... и когда я пишу menuItems.count
то cellForRow
не будет называться.
Я не понял, где я ошибаюсь.
Пожалуйста, любой может решить мою проблему. помощь будет заметна.
Точка останова на этой строке: 'NSLog (@" content =% @ ", content);' и проверить, не массив ли пуст. –
if (ResponseArray.count> 0) { self.menuItems = [[NSMutableArray alloc] initWithArray: ResponseArray]; } NSLog (@ "menu_itemes:% @", _ menuItems); в этом я получил ответ, который является правильным. –
ОК, но снова проверьте массив снова в cellForRowAtIndexPath: снова. –