daily pastebin goal
20%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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];
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top