Connection code to connect iphone to web server [closed]
Can anyone help me to connect iphone to web server??
Use ASIHTTPRequest for example as a library (to make it easier). You can even send POST requests to the website with the encoded parameters (see the documentation on the website).
you can always use NSURLRequest to build your request and NSURLConnection to start the connection.
I concur with Istvan, use ASIHTTPRequest for you calls. If you want more detail on how to write a local API in Objective-C, I wrote a blog post about this (uses ASIHTTPRequest as well, but is more about program design than the API itself):
http://longweekendmobile.com/2010/10/15/how-to-consume-json-or-xml-web-apis-on-iphone-smoothly/
Use this NSXMLParser Delegate method too
-(void)parseWithContentsofUrl:(NSURL*)url {
isParsingFinished = false;
rssParser = [[[NSXMLParser alloc] initWithContentsOfURL:url] autorelease];
[rssParser setDelegate:self];
[rssParser setShouldProcessNamespaces:NO];
[rssParser setShouldReportNamespacePrefixes:NO];
[rssParser setShouldResolveExternalEntities:NO];
[rssParser parse];
}
精彩评论