title: Xcode download db from server
body: <p>I am creating an app that uses a db to show data, but currently the db read it locally via FMDB. What I want to know is how can I download the db directly from a server and display it in the table view ?</p>
  
  <p>Code snippet:-</p>
  
  <pre><code>-(void)viewWillAppear:(BOOL)animated{
      NSString *path = [[NSBundle mainBundle] pathForResource:@"Climbing" ofType:@"db"];
  
      FMDatabase *db = [FMDatabase databaseWithPath:path];
      if (![db open]) {
          NSLog(@"Error Opening DB");
          return;
      }
      NSString *queryString;
      CDData *regioni;
  
      queryString = @"SELECT * , (SELECT count (*) FROM citta t WHERE t.id_regione = a.id_regione) as city FROM regione a ";
  
      FMResultSet *s = [db executeQuery:queryString];
      while ([s next]) {
          regioni = [[CDData alloc] initWithRecordSet:s];
          [self.data addObject:regioni];
  
      }
      [db close];
  }
  </code></pre>