2016-12-12 2 views
-1

이전 View 컨트롤러에서 여러 처방 제목을 표시했습니다. 특정 셀에 클릭 후에는 다음과 같이 서버에 다음보기로 가서 전화 : menu_items에서왜 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_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; 
    } 
) 

나는 다음과 같이 데이터를 표시 할 :

이를 위해

enter image description here

, 나는 다음과 같은 시도 :

나는 이것에 대해 화면에 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; 

} 

하지만 아무 것도 표시하지 않습니다. 내가 numberOfRowsInSection 다음,라는 cellForRow 1 줄 때

은 내가

NSLog(@"content = %@",content); 

에서 null있어 ... 그리고 난 다음 menuItems.count을 쓸 때 cellForRow가 호출되지 않습니다.

내가 잘못한 부분을 보지 못했습니다.

누구든지 내 문제를 해결할 수 있습니다. 도움이 상당 할 것입니다.

+0

이 줄에 중단 점을 배치하십시오. NSLog (@ "content = % @", content);'배열이 비어 있지 않은지 확인하십시오. –

+0

if (ResponseArray.count> 0) { self.menuItems = [[NSMutableArray alloc] initWithArray : ResponseArray]; } NSLog (@ "menu_itemes : % @", _ menuItems); 이것에서 나는 정확한 응답을 얻었다. –

+0

OK, 다시 cellForRowAtIndexPath :에서 배열을 확인하십시오. –

답변

0

self.menuItems은 어딘가에 재설정되지 않습니다. menuItems에 대한 setter 메서드를 작성하고 setter 메서드의 중단 점을 유지하여 수정중인 코드를 확인할 수 있습니다.

+0

또 다른 추측 (실제로 더 나은 것)은 @ Daij-Djan이 배열이 '약한'것으로 추측됩니다. 나는 OP가 더 많은 정보를 제공 할 때까지 이것에 대한 대답이 기다려야한다고 생각한다. – danh

관련 문제