Guest User

Untitled

a guest
Apr 16th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. [currentCities addObject:city];
  2.  
  3. if (sqlite3_prepare_v2(db, sql, -1, &statement, NULL) == SQLITE_OK){
  4. // We need to keep track of the state we are on
  5. NSString *state = @"none";
  6. NSMutableArray *currentCities = [NSMutableArray alloc];
  7.  
  8. // We "step" through the results - once for each row
  9. while (sqlite3_step(statement) == SQLITE_ROW){
  10. // The second parameter indicates the column index into the result set.
  11. int primaryKey = sqlite3_column_int(statement, 0);
  12. City *city = [[City alloc] initWithPrimaryKey:primaryKey database:db];
  13.  
  14. if (![state isEqualToString:city.state])
  15. {
  16. // We switched states
  17. state = [[NSString alloc] initWithString:city.state];
  18.  
  19. // Add the old array to the states array
  20. [self.states addObject:currentCities];
  21.  
  22. // set up a new cities array
  23. currentCities = [NSMutableArray init];
  24. }
  25.  
  26. [currentCities addObject:city];
  27. [city release];
  28. }
  29. }
  30.  
  31. // set up a new cities array
  32. currentCities = [NSMutableArray init];
  33.  
  34. // set up a new cities array
  35. [currentCities init];
  36.  
  37. NSMutableArray *currentCities = [[NSMutableArray alloc] init];
Add Comment
Please, Sign In to add comment