2013-06-13 51 views
-2

我正在创建表视图,并且不断收到未声明的标识符错误。我在源代码中评论了这些错误。iPhone - XCode未声明的标识符

- (void)loadTableView1 { 
UITableView *tableView1 = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 454) 
                 style:UITableViewStyleGrouped]; 
[tableView1 setDataSource:self]; 
[tableView1 setDelegate:self]; 


tableView1CellData = [[NSMutableArray alloc] init]; 
NSMutableArray *cells_1 = [[[NSMutableArray alloc] init] autorelease]; 
NSDictionary *cellContainer_1_1 = [[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"Website", @"Tap me to visit the Epiphany app!", @"", @"", @"", @"", nil] 
          forKeys:[NSArray arrayWithObjects:@"Text", @"Detail Text", @"Image", @"Text Color", @"Detail Text Color", @"Accessory", nil]] autorelease]; 
[cells_1 addObject:cellContainer_1_1]; 
NSDictionary *cellContainer_1_2 = [[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"ChurchWerks", @"Tap me to check your grades!", @"", @"", @"", @"", nil] 
          forKeys:[NSArray arrayWithObjects:@"Text", @"Detail Text", @"Image", @"Text Color", @"Detail Text Color", @"Accessory", nil]] autorelease]; 
[cells_1 addObject:cellContainer_1_2]; 
NSDictionary *cellContainer_1_3 = [[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"Calendar", @"Tap me for a list of upcoming events!", @"", @"", @"", @"", nil] 
          forKeys:[NSArray arrayWithObjects:@"Text", @"Detail Text", @"Image", @"Text Color", @"Detail Text Color", @"Accessory", nil]] autorelease]; 
[cells_1 addObject:cellContainer_1_3]; 
NSDictionary *cellContainer_1_4 = [[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"Weekly Work", @"Tap me for weekly work updates!", @"", @"", @"", @"", nil] 
          forKeys:[NSArray arrayWithObjects:@"Text", @"Detail Text", @"Image", @"Text Color", @"Detail Text Color", @"Accessory", nil]] autorelease]; 
[cells_1 addObject:cellContainer_1_4]; 
NSDictionary *cellContainer_1_5 = [[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"General Info", @"Tap me for info about Epiphany School!", @"", @"", @"", @"", nil] 
          forKeys:[NSArray arrayWithObjects:@"Text", @"Detail Text", @"Image", @"Text Color", @"Detail Text Color", @"Accessory", nil]] autorelease]; 
[cells_1 addObject:cellContainer_1_5]; 
NSDictionary *cellContainer_1_6 = [[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"Lunch Menu", @"Tap me & find out what's for lunch!", @"", @"", @"", @"", nil] 
          forKeys:[NSArray arrayWithObjects:@"Text", @"Detail Text", @"Image", @"Text Color", @"Detail Text Color", @"Accessory", nil]] autorelease]; 
[cells_1 addObject:cellContainer_1_6]; 
NSDictionary *sectionContainer_1 = [[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"The Epiphany School", cells_1, @"", nil] 
          forKeys:[NSArray arrayWithObjects:@"Title", @"Cells", @"Footer Title", nil]] autorelease]; 
[tableView1CellData addObject:sectionContainer_1]; 
NSMutableArray *cells_2 = [[[NSMutableArray alloc] init] autorelease]; 
NSDictionary *cellContainer_2_1 = [[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"Quia", @"Tune up your academic skills!", @"", @"", @"", @"", nil] 
          forKeys:[NSArray arrayWithObjects:@"Text", @"Detail Text", @"Image", @"Text Color", @"Detail Text Color", @"Accessory", nil]] autorelease]; 
[cells_2 addObject:cellContainer_2_1]; 
NSDictionary *cellContainer_2_2 = [[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"Mathletics", @"Tune up your math skills!", @"", @"", @"", @"", nil] 
          forKeys:[NSArray arrayWithObjects:@"Text", @"Detail Text", @"Image", @"Text Color", @"Detail Text Color", @"Accessory", nil]] autorelease]; 
[cells_2 addObject:cellContainer_2_2]; 
NSDictionary *cellContainer_2_3 = [[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"Quizlet", @"Prepare for your next exam w/ Quizlet!", @"", @"", @"", @"", nil] 
          forKeys:[NSArray arrayWithObjects:@"Text", @"Detail Text", @"Image", @"Text Color", @"Detail Text Color", @"Accessory", nil]] autorelease]; 
[cells_2 addObject:cellContainer_2_3]; 
NSDictionary *cellContainer_2_4 = [[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"BrainPop", @"Tune up your academics through BrainPop!", @"", @"", @"", @"", nil] 
          forKeys:[NSArray arrayWithObjects:@"Text", @"Detail Text", @"Image", @"Text Color", @"Detail Text Color", @"Accessory", nil]] autorelease]; 
[cells_2 addObject:cellContainer_2_4]; 
NSDictionary *sectionContainer_2 = [[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"Educational Websites", cells_2, @"", nil] 
          forKeys:[NSArray arrayWithObjects:@"Title", @"Cells", @"Footer Title", nil]] autorelease]; 
[tableView1CellData addObject:sectionContainer_2]; 


tableView1SelectedRow = 0; 
tableView1SelectedSection = 0; 
tableView1ShowHeader = YES; 
[tableView1 setEditing:NO]; 
[tableView1 setBackgroundColor:[UIColor colorWithRed:0.843137 green:0.850980 blue:0.874510 alpha:1.000000]]; 
[self addSubview:tableView1]; 
[tableView1 release]; 
} 

#pragma mark - 
#pragma mark TableView Delegates 

- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section { 
NSDictionary *sectionContainer = [tableView1CellData objectAtIndex:section]; 
NSMutableArray *cells = [sectionContainer objectForKey:tableView1"Cells"]; //use of undeclared identifier 'tableView1' 
return [cells count]; 
} 

编辑: 下面是从日志中的错误:

错误:使用未声明的标识符的 'tableView1'

NSMutableArray *cells = [sectionContainer objectForKey:tableView1"Cells"]; 
+0

完全错误,请张贴:) – madmik3

+3

你希望我们搜索语法错误在230代码行? - 请发布确切的错误消息和相关的代码行! –

+0

为什么xcode没有告诉你哪一行失败? –

回答

0

这个是什么意思:

[sectionContainer objectForKey:tableView1"Cells"]; 

或者您可以使用constent stringstring variable,或者如果必须使用两个字符串进行字符串比使用NSString方法。 你可以使用这样的:

NSMutableArray *cells = [sectionContainer objectForKey:@"Cells"]; 
+0

啊,谢谢!这是我的错误,我不知道为什么我把tableView1考虑为一个字符串。我的错! – LegitModern

0

而是这个

NSMutableArray *cells = [sectionContainer objectForKey:tableView1"Cells"]; 

使用此

NSMutableArray *cells = [sectionContainer objectForKey:@"Cells"]; 
+1

@“Cells”,它期望一个NSString,而不是一个C字符串。 – BergQuester

+0

哎呀错过了:) –