2016-12-12 7 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で与えるとき

iは

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はどこかでnilにリセットされているようです。 menuItemsのセッターメソッドを記述し、セッターメソッドでブレークポイントを保持して、どのコードが変更されているかを確認することができます。

+0

もう一つの推測(より良いものが実際にあります)は、@ Daij-Djanが配列が 'weak'と宣言されていると推測します。私はこれについての答えは、OPがより多くの情報を提供するまで待つべきだと思う。 – danh

関連する問題