Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [currentCities addObject:city];
- if (sqlite3_prepare_v2(db, sql, -1, &statement, NULL) == SQLITE_OK){
- // We need to keep track of the state we are on
- NSString *state = @"none";
- NSMutableArray *currentCities = [NSMutableArray alloc];
- // We "step" through the results - once for each row
- while (sqlite3_step(statement) == SQLITE_ROW){
- // The second parameter indicates the column index into the result set.
- int primaryKey = sqlite3_column_int(statement, 0);
- City *city = [[City alloc] initWithPrimaryKey:primaryKey database:db];
- if (![state isEqualToString:city.state])
- {
- // We switched states
- state = [[NSString alloc] initWithString:city.state];
- // Add the old array to the states array
- [self.states addObject:currentCities];
- // set up a new cities array
- currentCities = [NSMutableArray init];
- }
- [currentCities addObject:city];
- [city release];
- }
- }
- // set up a new cities array
- currentCities = [NSMutableArray init];
- // set up a new cities array
- [currentCities init];
- NSMutableArray *currentCities = [[NSMutableArray alloc] init];
Add Comment
Please, Sign In to add comment