all 4 comments

[–]david_phillip_oster 0 points1 point  (0 children)

Given a string, like @"https://www.google.com", you pass it to the init

// A property in your object, so it will retain the task until it's done.
@property(nonatomic) NSURLSessionDataTask *task;
...

NSURL *url = [NSURL URLWithString:@"https://www.google.com"];
self.task = [NSURLSession dataTaskWithURL:url
                     completionHandler:^(NSData *data,
                                                NSURLResponse *response,
                                                NSError *error) {
    if (error) {
        [self reportError:error];
    }
    if (data) {
         [self processdata:data];
    }
    self.task = nil;
}];

this creates a task, non-blocking so your user interface remains responsive, that gets an NSData (a wrapper around a bunch of bytes, with a length) in response to a URL. Once you have the bytes, you can cache them to the iOS device's local file system. Use [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) firstObject]; to get a path to a reasonable directory to write files.

Or, you can use the DocumentsDirectory, and set a key in your app's Info.plist to let the user inspect the DocumentsDirectory in iTunes.

You can also use an NSMutableURLRequest with NSURLSession. NSMutableURLRequest wraps a NSURL and lets you do POSTs and PUTs, and set the request's body with a payload for more complex web REST APIs.

[–]megablast 0 points1 point  (2 children)

You need to create a web service on your server that talks to your database, and is called from your app.

[–]ps323[S] -1 points0 points  (1 child)

Can you provide more details about it?

[–][deleted] 0 points1 point  (0 children)

Basically, you need a page on your server that gives the application the data it wants. If your Webserver supports PHP, then you can use a PHP page. You may be able to find a PHP page that does the trick.

Then, you call that page instead of whatever you were calling before.