我想访问从 UIViewcontroller 类的数据库中获取的 DBhelper 类中的数据,我已经导入了类、创建的对象、方法和所有变量都可以在 UIViewcontroller 类中访问。当通过 uiviewcontroller 类调用方法时,它们显示数据库结果或分配要执行的任何方法,但是当通过对象在 uiviewcontroller 中使用这些变量/数组时,它们返回 null。即使我也实现了 prperties 并合成了它们.. 这是我的代码
-(NSMutableArray *) SaveDBInArray {
[self createEditableCopyOfDatabaseIfNeeded];
[self initializeDatabase];
const char *sql = "SELECT * FROM table11";
if (sqlite3_prepare_v2(database, sql, -1, &init_statement, NULL) != SQLITE_OK) {
//NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database)); }
while (sqlite3_step(init_statement) == SQLITE_ROW) {
colum1= [NSString stringWithUTF8String:(char *)sqlite3_column_text(init_statement,0)];
colum2= [NSString stringWithUTF8String:(char *)sqlite3_column_text(init_statement,1)];
allEnteries=[[NSMutableArray alloc]init];
[allEnteries addObject:colum1];
[allEnteries addObject:colum2];
}
NSLog(@"array with values %@",allEnteries );
//HERE WHENEVER METHOD IS BEING CALLED IT IS DISPLAYING ONLY TOP ONE VALUE FROM EACH COLUM BUT I WANT ALL OF THEM
sqlite3_reset(init_statement);
[self closeDatabase];
return allEnteries;
}