-2

我正在创建一个表格视图,并且不断收到未声明的标识符错误。我已经在我的源代码中注释了错误。

- (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"];
4

2 回答 2

0

而不是这个

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

用这个

NSMutableArray *cells = [sectionContainer objectForKey:@"Cells"];
于 2013-06-13T04:46:06.743 回答
0

这是什么意思 :

[sectionContainer objectForKey:tableView1"Cells"];

您可以使用constent string, a string variable,或者如果您必须使用两个字符串而不是使用NSString方法来制作字符串。你可以像这样使用:

NSMutableArray *cells = [sectionContainer objectForKey:@"Cells"];
于 2013-06-13T04:19:57.703 回答