2017-03-06 5 views
0

以下はサービスから取得する配列です。サービスからの出力を表示する際の問題Objective-C

{ 
    ClassDays = "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday"; 
    empName = Abhinav; 
    Experience = "4 Years"; 
    Attendance = Daily; 
    Subject = Physics; 
    ClassTimings =  (
         { 
          GMT = "PLUS05:30"; 
          Time = "12:50:00"; 
          TimeZone = "Asia/Hyderabad"; 
         }, 
         { 
          GMT = "PLUS05:30"; 
          Time = "13:00:00"; 
          TimeZone = "Asia/Hyderabad"; 
         }, 
         { 
          GMT = "PLUS05:30"; 
          Time = "13:10:00"; 
          TimeZone = "Asia/Hyderabad"; 
         }, 
         { 
          GMT = "PLUS05:30"; 
          Time = "13:20:00"; 
          TimeZone = "Asia/Hyderabad"; 
         } 
         ); 
    JoinedDate = "2017-003-06"; 
    Education = M.Tech; 
    empId = 535; 
} 

私の問題は、のempNameの値を示すことができ、上記アレイの出力午前、経験、出席、件名や教育、しかしClassTimings GMT、時間、タイムゾーンを表示することができないからです。 ClassTimingsを下の配列からどのように表示できますか?以下は私が試したコードです。問題を見つけるのを手伝ってください。 TIA

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 


    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) 
    { 

     //Some code 
    } 

    NSArray *keys = [empDict allKeys]; 

    for(int i=0 ; i<[keys count]; i++) 
    { 

     NSString *value=[medicationDict objectForKey:[keys objectAtIndex:i]]; 
     if ([value isEqual: [NSNull null]]) { 

      [empDict setValue:@"--" forKey:[keys objectAtIndex:i]]; 

     } 

    } 

    if(indexPath.row==0) 
    { 
     cell.textLabel.text = @"EmployeeName"; 
     cell.detailTextLabel.text=[empDict objectForKey:@"empName"]; 
    } 

    if(indexPath.row==1) 
    { 
     cell.textLabel.text = @"Experience"; 
     cell.detailTextLabel.text=[empDict objectForKey:@"Experience"]; 
    } 

    if(indexPath.row==2) 
    { 
     cell.textLabel.text = @"Attendance"; 
     cell.detailTextLabel.text=[empDict objectForKey:@"Attendance"]; 
    } 
    if(indexPath.row==3) 
    { 
     cell.textLabel.text = @"Subject"; 
     cell.detailTextLabel.text=[empDict objectForKey:@"Subject"]; 
    } 
    if(indexPath.row==4) 
    { 
     cell.textLabel.text = @"Education"; 
     cell.detailTextLabel.text=[empDict objectForKey:@"Education"]; 
    } 
    if(indexPath.row==5) 
    { 
     cell.textLabel.text = @"ClassTimings"; 
     cell.detailTextLabel.text=[empDict objectForKey:@"GMT", 
            @"Time",@"TimeZone"]; 
    } 
} 
+0

'ClassTimings'はあなたのセルにtableViewを追加する必要があります。 –

答えて

0

シンプルClassTimingsがあなたのJsonDictionary

からの配列を作っているので、あなたが唯一つだけの行を表示した場合

if(index path.row ==5) 
{ 
NSString *stgmt = [empDict objectForKey:@"GMT"];; 

NSString *strtime = [empDict objectForKey:@"Time"];; 

NSString *strtimeZone = [empDict objectForKey:@"TimeZone"]; 
} 

//あなたのJSONから配列を取得し、テーブルビューのインデックスパスの行に渡すことができます配列を作成し、その論理よりも各テーブルビューの行を表示する場合

yourArray = [jsonDict objectForKey:@"ClassTimings"]; 
NSString *stgmt = [yourArray objectAtIndex:indexPath.row]objectForKey:@"GMT"];; 

NSString *strtime = [yourArray objectAtIndex:indexPath.row]objectForKey:@"Time"];; 

NSString *strtimeZone = [yourArray objectAtIndex:indexPath.row]objectForKey:@"TimeZone"];; 
+0

これは 'if(indexPath.row == 5)'で、静的インデックスです –

+0

GMT、Time、TimeZoneをラベルに割り当てる方法 – Rajeev

+0

stgmt、strtime、strtimeZoneこのパスではこの値を取得しますラベル内 –

関連する問題