Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Check out the documentation for <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/Reference/Reference.html" rel="nofollow noreferrer"><code>NSURLRequest</code></a> (and <a href="http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSMutableURLRequest_Class/Reference/Reference.html" rel="nofollow noreferrer"><code>NSMutableURLRequest</code></a>): you can use it to make a <code>POST</code> request to your login and registration pages, just like a web browser. You can write the form UI in Cocoa/Objective-C and then send the data to the server.</p> <p>As far as displaying the result to the user, you'll have to figure out a way to either parse the returned HTML (bad idea) or modify your CMS to return JSON or XML to iPhone requests (better idea).</p> <p><strong>Edit:</strong> Here's some sample code, taken from an app I'm working on (it submits data to Last.fm using <code>POST</code>):</p> <pre><code>NSURL *url = [NSURL URLWithString:@"http://example.com/"]; NSString *str = @"This is my example data!"; // everything below here is directly from my app: NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; [request setHTTPBody:[str dataUsingEncoding:NSUTF8StringEncoding]]; [request setValue:kLastFMClientUserAgent forHTTPHeaderField:@"User-Agent"]; [request setCachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData]; [request setHTTPShouldHandleCookies:NO]; *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES]; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload