title: Retrieving Position, Title, and Snippet for Multiple Markers Using Google Maps for iOS
body: <p>The problem I'm having it that when I long touch the map it saves the data to Core Data and I can retrieve this data by NSLogs but I cannot figure out how to create multiple map markers from this data. Can anyone give me an example of a for loop for drawing these markers?</p>
  
  <pre><code>    -(void) mapView:(GMSMapView *)mapView didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate{
      location = coordinate;
      [self alertview1];
  }
  
  - (void) alertview1 {
      UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Save Map Location" message:@"Enter   Title &amp; Description" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
      [av setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
  
      [[av textFieldAtIndex:1] setSecureTextEntry:NO];
      [[av textFieldAtIndex:0] setPlaceholder:@"Title"];
      [[av textFieldAtIndex:1] setPlaceholder:@"Description"];
      [av show];
  }
  - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
      if (buttonIndex != alertView.cancelButtonIndex) {
      markerTitle = [alertView textFieldAtIndex:0].text;
      markerSnippet = [alertView textFieldAtIndex:1].text;
      NSLog(@"1 %@", [alertView textFieldAtIndex:0].text);
      NSLog(@"2 %@", [alertView textFieldAtIndex:1].text);
      [self saveMarker];
  
  
  }
  - (void) saveMarker{
      NSManagedObjectContext *context = [self managedObjectContext];
  
      NSManagedObject *newDevice = [NSEntityDescription insertNewObjectForEntityForName:@"Marker"  inManagedObjectContext:context];
      [newDevice setValue:[NSNumber numberWithDouble:location.latitude] forKey:@"latitude"];
      [newDevice setValue:[NSNumber numberWithDouble:location.longitude] forKey:@"longitude"];
      [newDevice setValue:markerTitle forKey:@"title"];
      [newDevice setValue:markerSnippet forKey:@"snippet"];
  
      NSError *error = nil;
      if (![context save:&amp;error]) {
      NSLog(@"Can't Save! %@ %@", error, [error localizedDescription]);
      }
  
      [self dismissViewControllerAnimated:YES completion:nil];
      [self fetchMarkers];
      }
  - (void) fetchMarkers {
      NSManagedObjectContext *managedObjectContext = [self managedObjectContext];
      NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"Marker"];
      self.markers = [[managedObjectContext executeFetchRequest:fetchRequest error:nil] mutableCopy];
  
      NSArray *title = [self.markers valueForKey:@"Title"];
      NSArray *snippet = [self.markers valueForKey:@"Snippet"];
      NSArray *latitude = [self.markers valueForKey:@"Latitude"];
      NSArray *longitude = [self.markers valueForKey:@"Longitude"];
      NSLog (@"%@", title);
      NSLog (@"%@", snippet);
      NSLog (@"%@", latitude);
      NSLog (@"%@", longitude);
      double lat = [latitude doubleValue];
      double lng = [longitude doubleValue];
  
      for (GMSMarker *marker in title) {
          GMSMarker *mkr = [[GMSMarker alloc] init];
          [mkr setPosition:CLLocationCoordinate2DMake(lat,lng)];
          [mkr setAnimated:YES];
          [mkr setTitle:title];
          [mkr setSnippet:snippet];
          [mkr setMap:self.mapView1];
  
  }
  
  }
  </code></pre>