【发布时间】:2017-03-06 07:02:34
【问题描述】:
下面是我从服务中获得的数组。
{
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、Experience、Attendance、Subject 和 Education 的值,但无法显示 ClassTimings GMT、Time、TimeZone。我如何从数组下方显示 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"];
}
}
【问题讨论】:
-
ClassTimings是字典数组,因此您需要在单元格中添加 tableView。
标签: ios objective-c iphone xcode nsarray