现在,我收到有关尝试从对象读取数据的表视图单元格的错误。我正在访问一个数据库,将所有行作为对象存储到一个 NSMUtable 数组中,这似乎工作正常。但是当我希望表格视图读取该数组时,我不断得到“空”。任何帮助将不胜感激。
错误
-[AttendeeData isEqualToString:]:无法识别的选择器发送到实例 0x751ca80 2013-03-16 11:40:52.499 ExpoRequestLite[39716:c07] *由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,
@interface DashLandingViewController ()
@end
@implementation DashLandingViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self){
// Custom initialization
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
entries = [[NSMutableArray alloc]init];
_attendeeDataToPush = [[AttendeeData alloc]init];
[self openDB];
NSString *sql = [NSString stringWithFormat:@"SELECT * FROM data"];
sqlite3_stmt *statement;
if(sqlite3_prepare_v2(db, [sql UTF8String], -1, &statement, nil)== SQLITE_OK) {
while(sqlite3_step(statement) == SQLITE_ROW){
NSLog(@"got all attendees");
NSString *firstName = [[NSString alloc] initWithUTF8String:(const char *)sqlite3_column_text(statement, 2)];
_attendeeDataToPush.firstNameValue = firstName;
[entries addObject:_attendeeDataToPush];
NSLog(@"array has %@", [[entries objectAtIndex:0] firstNameValue]);
}
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [entries count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSLog(@"selected firstname is %@", [[entries objectAtIndex:0] firstNameValue]);
cell.textLabel.text = [entries objectAtIndex:indexPath.row];
return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
@end