I have this function that accepts the results of a database query. I am using the FMDB library to query the database. However, I get the feeling that I am not passing the query results correctly to my mutable array. Here is my fucntion
-(NSArray *)initializeGroupIDArray{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsPath = [paths objectAtIndex:0];
NSString *dbPath = [docsPath stringByAppendingPathComponent:@"itemList.db"];
FMDatabase *database = [FMDatabase databaseWithPath:dbPath];
[database open];
NSString *sqlSelectQuery = @"SELECT DISTINCT GROUPID FROM ItemList";
FMResultSet *resultsWithNameLocation = [database executeQuery:sqlSelectQuery];
while([resultsWithNameLocation next]) {
NSString *itemName = [NSString stringWithFormat:@"%@",[resultsWithNameLocation stringForColumn:@"GROUPID"]];
NSLog(@"GroupID = %@", itemName);
[groupArray addObject:itemName];
}
[database close];
NSArray *groupID;
[groupID = groupArray copy];
return groupID;
}
A warning appears in the lines of NSLog(@"GroupID = %@", itemName);and [groupArray addObject:itemName];stating that the local declaration is itemNamehiding the instance variable. I have a feeling that behind this I cannot properly add the results to my array. Can someone point out what I'm doing wrong? Thank.
source
share