небольшое уточнение: возможно ли открыть две таблицы из одной базы данных sqlite в одном классе iphone ??? но я не могу открыть его, пожалуйста, дайте мне решение, я новичок
здесь я попробовал кодировать
- (void)viewDidLoad {
[super viewDidLoad];
list = [[NSMutableArray alloc] init];
if ([material isEqualToString:@"Derlin"]) {
[self sel1];
}
else if([material isEqualToString:@"Helers"]){
[self sel2];
}
}
-(void)sel1 {
[self createEditableCopyOfDatabaseIfNeeded];
NSLog(@"numberOfRowsInSection");
sqlite3_stmt *statement = nil; // create a statement
const char *sql = "Select * from material"; //create a query to display in the tableView
if(sqlite3_open([writableDBPath UTF8String], &database) == SQLITE_OK)
{
NSLog(@"sqlite3_open");
if(sqlite3_prepare_v2(database, sql,-1, &statement, NULL)!=SQLITE_OK)
NSAssert1(0,@"Error Preparing Statement",sqlite3_errcode(database));
else
{
while(sqlite3_step(statement) == SQLITE_ROW) // if the connection exists return the row of the query table
{
achemical = [NSString stringWithFormat:@"%s",(char *)sqlite3_column_text(statement,0)];
arates = [NSString stringWithFormat:@"%s",(char *)sqlite3_column_text(statement,1)];
anotes = [NSString stringWithFormat:@"%s",(char *)sqlite3_column_text(statement,2)];
Chemical * chemic = [[Chemical alloc] initWithName:achemical rates:arates notes:anotes];
[list addObject:chemic];
[chemic release];
}
}
}
sqlite3_finalize(statement);
}
-(void)sel2 {
[self createEditableCopyOfDatabaseIfNeeded];
NSLog(@"numberOfRowsInSection");
sqlite3_stmt *statement = nil; // create a statement
const char *sql = "Select * from material1"; //create a query to display in the tableView
if(sqlite3_open([writableDBPath UTF8String], &database) == SQLITE_OK)
{
NSLog(@"sqlite3_open");
if(sqlite3_prepare_v2(database, sql,-1, &statement, NULL)!=SQLITE_OK)
NSAssert1(0,@"Error Preparing Statement",sqlite3_errcode(database));
else
{
while(sqlite3_step(statement) == SQLITE_ROW) // if the connection exists return the row of the query table
{
achemical = [NSString stringWithFormat:@"%s",(char *)sqlite3_column_text(statement,0)];
arates = [NSString stringWithFormat:@"%s",(char *)sqlite3_column_text(statement,1)];
anotes = [NSString stringWithFormat:@"%s",(char *)sqlite3_column_text(statement,2)];
Chemical * chemic = [[Chemical alloc] initWithName:achemical rates:arates notes:anotes];
[list addObject:chemic];
[chemic release];
}
}
}
sqlite3_finalize(statement);
}
спасибо заранее