Ios 显示服务目标C的输出时出现问题
下面是我从服务中获得的数组Ios 显示服务目标C的输出时出现问题,ios,objective-c,iphone,xcode,nsarray,Ios,Objective C,Iphone,Xcode,Nsarray,下面是我从服务中获得的数组 { ClassDays = "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday"; empName = Abhinav; Experience = "4 Years"; Attendance = Daily; Subject = Physics; ClassTimings = ( {
{
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、经验、出勤率、科目和教育程度的值,但不能显示上课时间GMT、时间、时区。如何从下面的数组显示类计时。下面是我尝试过的代码。请帮我找出问题所在。短暂性脑缺血发作
- (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"];
}
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
静态NSString*CellIdentifier=@“Cell”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
如果(单元格==nil)
{
//一些代码
}
NSArray*键=[empDict allkey];
对于(inti=0;iSimple),您可以从Json获取数组并传入tableview索引路径行,因为类计时正在从JsonDictionary生成数组
如果只显示一行
if(index path.row ==5)
{
NSString *stgmt = [empDict objectForKey:@"GMT"];;
NSString *strtime = [empDict objectForKey:@"Time"];;
NSString *strtimeZone = [empDict objectForKey:@"TimeZone"];
}
//如果要生成数组并显示每个tableview行,请检查其逻辑
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"];;
ClassTimings
是字典数组,因此您需要在单元格中添加tableView。您是否看到了此如果(indexPath.row==5)
,它是静态索引当我如何将GMT、Time和TimeZone分配给labelstgmt、strtime、strtimeZone时,您将在此过程中获得值在label中传递此值