在过去的几年中(iOS8 / XCode 6之前的版本),此代码按以下顺序生成了一个表格:
设备名称燃烧气体分析安全检查设备检查结果与完成现在在iOS8 / XCode 6中翻转NSMutableDictionary中两个NSMutableArray的顺序,因此它输出
燃烧气体分析安全检查设备检查结果与完成设备名称为什么???
#import "svServiceVC.h" #import "SingletonID.h" #import "escgasDatabase.h" #import "FMDBDataAccess.h" @interface svServiceVC () @end @implementation svServiceVC - (void)viewDidLoad { [super viewDidLoad]; self.theTable.delegate = self; self.theTable.dataSource =self; } - (void)viewWillAppear:(BOOL)animated { [self buildTableData]; [_theTable reloadData]; } - (void)buildTableData { anApplianceNamed = 0; generalInspectationDone = 0; _appliancesDict = [[NSMutableDictionary alloc] init]; [_appliancesDict setValue:[[NSMutableArray alloc] init] forKey:@"Appliances"]; [_appliancesDict setValue:[[NSMutableArray alloc] init] forKey:@"Inspection"]; // snip [[_appliancesDict objectForKey:@"Appliances"] addObject:appString1]; [[_appliancesDict objectForKey:@"Inspection"] addObject:@"Combustion gas analysis"]; [[_appliancesDict objectForKey:@"Inspection"] addObject:@"Safety checks"]; [[_appliancesDict objectForKey:@"Inspection"] addObject:@"Appliance checks"]; [[_appliancesDict objectForKey:@"Inspection"] addObject:@"Findings & Completion"]; generalInspectationDone = 1; } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [_appliancesDict count]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [[_appliancesDict valueForKey:[[_appliancesDict allKeys] objectAtIndex:section]] count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"AppCell"; UITableViewCell *cell; NSArray *versionCompatibility = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; if ( 6 <= [[versionCompatibility objectAtIndex:0] intValue] ) { // iOS6 is installed cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; } else { // iOS5 is installed cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier ]; } NSString *appTitle = [[_appliancesDict valueForKey:[[_appliancesDict allKeys] objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row]; cell.textLabel.text = appTitle; if (indexPath.section==0) { // The appliance cells if ([cell.textLabel.text hasPrefix:@"Appliance"]) { cell.textLabel.textColor = [UIColor lightGrayColor]; } else { cell.textLabel.textColor = [UIColor blackColor]; } } else { // The inspection rows if (indexPath.row==0) { // if (gasInspection==0) { cell.textLabel.textColor = [UIColor lightGrayColor]; } else { cell.textLabel.textColor = [UIColor blackColor]; } } else if (indexPath.row==1) { // * Gas inpsection if (safetyChecks==0) { cell.textLabel.textColor = [UIColor lightGrayColor]; } else { cell.textLabel.textColor = [UIColor blackColor]; } } else if (indexPath.row==2) { // * Gas inpsection if (applianceChecks==0) { cell.textLabel.textColor = [UIColor lightGrayColor]; } else { cell.textLabel.textColor = [UIColor blackColor]; } } else if (indexPath.row==3) { if (generalInspectationDone==0) { //cell.textLabel.textColor = [UIColor lightGrayColor]; cell.textLabel.textColor = [UIColor blackColor]; } else { cell.textLabel.textColor = [UIColor blackColor]; } } } return cell; } #pragma mark - Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"didSelectRowAtIndexPath:indexpath %li %li",(long)indexPath.section, (long)indexPath.row); switch (indexPath.section) { case 0: // Appliances [SingletonID sharedSingleton].appliance = @"_1"; [self performSegueWithIdentifier:@"svApplianceSegue" sender:self]; break; case 1: switch (indexPath.row){ case 0: [self goGasAnalysis]; break; case 1: [self goSafety]; break; case 2: [self goChecks]; break; case 3: [self goComplete]; break; default: break; } } }