Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your app does not perform the actual query. The proper way to do this is to set up an API for your website so that the site does the querying and returns the appropriate data to your app.</p> <p>Your API is generally going to be comprised of a number of end points that return data formatted for your app. For example, you might create a PHP or Python page that queries your database for all of the posts for a given user and returns them in a JSON or XML encoded array. (The data format is totally up to you. There are frameworks for parsing both formats available for iOS.) </p> <p>For example, let's say you have a PHP page on your server that returns the current day of the week. Your PHP would look something like this:</p> <pre><code>&lt;?php echo date("l"); ?&gt; </code></pre> <p>Let's imagine that you've saved this as <a href="http://example.com/dayoftheweek.php" rel="nofollow noreferrer">http://example.com/dayoftheweek.php</a></p> <p>I recommend using the <a href="http://allseeing-i.com/ASIHTTPRequest/" rel="nofollow noreferrer">ASIHTTPRequest</a> framework for performing HTTP requests from within your app. That said, let's go ahead and set up a connection to your PHP page. Assuming you have ASIHTTPRequest all set up in your project, here's what a request might look like:</p> <pre><code>NSURL *url = [NSURL URLWithString:@"http://example.com/dayoftheweek.php"] ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:url]; [request setDelegate:self]; </code></pre> <p>Now, you need implement the ASIHTTPRequest Delegate methods, to parse the returned data. The method which handles a completed request is shown here:</p> <pre><code>- (void)requestFinished:(ASIHTTPRequest *)request{ //Here you would store the returned data and/or parse it } </code></pre> <p>To implement an API, your PHP pages would be more complex. You would build a more complex request , passing in variables and such, and the PHP page would act like a regular web service, returning the data that you have requested.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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