Send data from iPhone to web service

I am developing an iPad application in which the user fills in their data and presses the submit button, which sends information to a specific web server (which will later be viewed by a person)

Regarding protocols for web services, I know JSON and XML. Are there any other protocols I should look at? (or, possibly, in another way completely)

I would be very grateful for any help.

+4
source share
4 answers

If you want to send text information to the server, you can try this code:

NSString *textdata = [YourTextField text]; NSString *anotherTextdata = [YourAnotherTextField text]; NSString *urlpath; urlpath = [@"http://yoursiteapiurl.com/" stringByAppendingString:@"yourserverfile.php?textdata="]; urlpath = [urlpath stringByAppendingString:textdata]; urlpath = [urlpath stringByAppendingString:@"&anotherTextData="]; urlpath = [urlpath stringByAppendingString:anotherTextdata]; NSURL *url=[[NSURL alloc] initWithString:[urlpath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSString *a = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil]; 

Variable a will have the response of this url. The server can send XML, and then you can parse this XML using any XML parsing method.

+4
source

you can use tbxml for it, it is very easy to implement. Follow the link

http://www.tbxml.co.uk/TBXML/TBXML_Free.html

+1
source

If sending data over HTTP is an option, I would recommend that you study the excellent ASIHTTPRequest library. Regarding the encoding, I found the json-framework library is good.

+1
source

Use AFNetworking for this.

AFNetworking is smart enough to download and process structured data over the network, as well as plain old HTTP requests. In particular, it supports JSON, XML, and property lists (plists).

0
source

Source: https://habr.com/ru/post/1346665/


All Articles