我需要对所有栏目进行搜索,而不是在我想要制定一种能够通过所有栏目搜索的方法的栏目中注明每个栏目。
-(void) fillSomeobjectNames:(NSString *)filter
{
FMDatabase *db = [FMDatabase databaseWithPath:databasePath];
[db open];
NSString *sql = [NSString stringWithFormat:@"SELECT id, name, imagefile FROM %@ %@", mainTableName, filter];
FMResultSet *results = [db executeQuery:sql];
while([results next])
{
Someobject *someobject = [[Someobject alloc] init];
[someobject setID:[results intForColumn:@"id"]];
[someobject setName:[results stringForColumn:@"name"]];
NSString *iconName = [[results stringForColumn:@"imagefile"] stringByReplacingOccurrencesOfString:@".jpg" withString:@""];
[someobject setIconPath:[NSString stringWithFormat:@"%@-ico.jpg",iconName]];
[someobjects someobject];
}
[db close];
}
过滤器可以是WHERE 标记=[研究范围]和描述=[研究范围]等。