Iphone 滚动表视图时出现问题
滚动表格视图时出现以下问题:Iphone 滚动表视图时出现问题,iphone,ios,uitableview,Iphone,Ios,Uitableview,滚动表格视图时出现以下问题: NSCFString objectAtIndex:]: unrecognized selector sent to instance 我创建NSDictionary tableContents,当我滚动它时,它将被释放。 这是我的代码: - (void)viewDidLoad { lessonsInGroup1 = [NSMutableArray array]; lessonsInGroup2 = [NSMutableArray array]; lessonsI
NSCFString objectAtIndex:]: unrecognized selector sent to instance
我创建NSDictionary tableContents,当我滚动它时,它将被释放。
这是我的代码:
- (void)viewDidLoad {
lessonsInGroup1 = [NSMutableArray array];
lessonsInGroup2 = [NSMutableArray array];
lessonsInGroup1 = [self grabRowsInGroup:@"1"];
lessonsInGroup2 = [self grabRowsInGroup:@"2"];
NSDictionary *temp =[[NSDictionary alloc]initWithObjectsAndKeys:lessonsInGroup1,@"General Information",lessonsInGroup2,@"LaTeX Examples", nil];
//[[tableContents alloc] init];
self.tableContents =temp;
[temp release];
NSLog(@"table %@",self.tableContents);
NSLog(@"table with Keys %@",[self.tableContents allKeys]);
self.sortedKeys =[[self.tableContents allKeys] sortedArrayUsingSelector:@selector(compare:)];
NSLog(@"sorted %@",self.sortedKeys);
[lessonsInGroup1 release];
[lessonsInGroup2 release];
//[table reloadData];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
[super viewDidLoad];
}
}目录的@property是什么样子的 此外,您还将遇到以下问题:
[lessonsInGroup1 release];
[lessonsInGroup2 release];
因为您正在自动删除GrabRowsingGroup中的内容:
因此,您不需要调用release它们。看起来您是在NSString上调用objectAtIndex。它应该是一些数组@属性(非原子,保留)NSDictionary*tableContents;谢谢,达伦。你是对的。我的类字段属性如下:@property(非原子,赋值)NSString*LessonText;我以为你们在问我字典的性质,没关系。但后来我又发现了一个关于这个问题的话题,我知道这件事发生在字典中我的对象字段中。因此,权限不是assign,而是retain。如果发生sql错误,则泄漏groupOfLessons对象。事实上,在你应该归还的时候,你什么也没归还。是的,我知道。我将其称为字典,但iPhone认为我将其称为字符串,因为当我滚动时,字典会以某种方式被解除分配。
[lessonsInGroup1 release];
[lessonsInGroup2 release];