- (IBAction)publishAd:(id)sender
{
   NSArray *keys = [NSArray arrayWithObjects:@"name", @"city", @"price", nil];
   NSArray *values = [NSArray arrayWithObjects:nameTextField.text, 
                        cityTextField.text, priceTextField.text, nil];
   NSDictionary *ad = [NSDictionary dictionaryWithObjects:values 
                                                  forKeys:keys];

   NSError *error;

   if ([RentalManagerAPI publishAd:ad error:&error]) {
       UIAlertView *av = [[UIAlertView alloc] 
                            initWithTitle:@"Sukces"
                                  message:@"Operacja zakończona powodzeniem." 
                                 delegate:nil
                        cancelButtonTitle:@"OK" 
                        otherButtonTitles:nil];
      [av show];
      [av release];
   } else {
      NSString *message;
      if ([error domain] == RMAErrorDomain) {
         switch ([error code]) {
             case RMAValidationError:
                 message = [NSString stringWithFormat:@"%@\nBrakujące wartości: %@.",
                        [error localizedDescription],
                        [[[error userInfo] objectForKey:RMAMissingValuesKey] 
                               componentsJoinedByString:@", "]];
                 break;
              case RMAWrongCredentialsError:
                 break;
              default:
                 message = [error localizedDescription];
                 break;
         }
      } else {
         message = [error localizedDescription];
      }
      UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Błąd"
                                                   message:message 
                                                  delegate:nil
                                         cancelButtonTitle:@"OK" 
                                         otherButtonTitles:nil];
      [av show];
      [av release];
   }
}
