[objective-c]EGODatabase #7 テーブル一覧取得
テーブル一覧取得
-(NSArray*)getTableNameList{ EGODatabase*db=[self getDB]; NSString*sql=@"select name from sqlite_master where type = 'table' order by name"; EGODatabaseResult*result=[db executeQuery:sql]; NSMutableArray*list=[NSMutableArray arrayWithCapacity:[result count]]; for (EGODatabaseRow*row in result) { [list addObject:[row stringForColumn:@"name"]]; } return [NSArray arrayWithArray:list]; } -(EGODatabase*)getDB{ EGODatabase* database = [EGODatabase databaseWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/database.db"]]; return database; } -(BOOL)isExistTableByName:(NSString*)tableName{ NSArray*tables=[self getTableNameList]; return [tables containsObject:tableName]; }