Entering text field values ​​in a URL

So, I'm developing an application, but now I'm a bit stuck. I have 2 text fields right now when the user will have to enter:

Ordernr:xxxxxxxx Referencenr:xxxxxxx 

these 2 values ​​should be added to this link: http://www.artis-web.de/cgi-bin/WebObjects/Artis.woa/wa/detailedTrack?referencenr=xxxxxxxx&ordernr=xxxxxxxxxx

now i want safari to open this link. The ideal situation is that the user enters the values ​​of 2 text fields, and then clicks the "open in safari" button

What would be the best way to implement this?

+4
source share
3 answers

Just add the following code to your button action:

 NSString *urlString = [NSString stringWithFormat:@"http://www.artis-web.de/cgi-bin/WebObjects/Artis.woa/wa/detailedTrack?referencenr=%@&ordernr=%@", referenceNrTextField.text, orderNrTextField.text]; [[UIApplication sharedApplication] openURL: [NSURL URLWithString: urlString]]; 
+5
source

To create a url that you can use ...

 NSURL *url = [NSURL urlWithString:[NSString stringWithFormat:@"http://www.artis-web.de/cgi-bin/WebObjects/Artis.woa/wa/detailedTrack?referencenr=%@&ordernr=%@", referenceTextField.text, ordernoTextField.text]]; 

Open in safari ...

 [[UIApplication sharedApplication] openURL:url]; 
+3
source

Check if both fields have data, and then click on the data URL. This condition would be sufficient.

  if (Ordernr.text.length!=0 && Referencenr.text.length!=0) { NSLog(@"Hit the Url with the entered data"); } else { NSLog (@"Show Error Alert Message"); } 
+1
source

All Articles