Swift: Using External Databases and API's Part 2: The App

Jacob Schatz · 45K views · 2014 · 21:13

Open on YouTube

Web developmentSoftware practice, open source & careerstutorialdated

Why Stack Overflow recommends it

Stack Overflow users cite it as the tutorial they were following when they hit problems wiring a Swift iOS app to a Rails or PHP backend and parsing the JSON.

Recommended by 0 people across 0 different months, 2014 to 2016.

What it is

A 21-minute screencast by Jacob Schatz, part two of a series on building an early Swift iOS app that talks to an external database and web API. It walks through the app code that fetches JSON from a backend, with the source on GitHub as BlogtaculousApp.

What people said

Cites mharris7190 · 2014-11 · Stack Overflow · on “rails render json returns array instead of dictionary”

If I have a standard Post resource (model) and in my index action have: # GET /posts # GET /posts.json def index @posts = Post.all render json: @posts end and there's only 1 post in @posts, I get back something like [{"id": 1, "title":"ImaPost"}] but I (think I) want to get back something more like {"posts": ["Post":{"id": 1, "title":"ImaPost"}]} The reason I am trying to do this is because I am follow this tutorial [this video] for using an api with swift for iOS dev, but it's my first time creating an API and its my first time using something like this with swift.

Cites SagittariusA · 2015-08 · Stack Overflow · on “Swift: How to use NSURLSession to query external database?”

I am writing this question because I am in a big difficulty in understanding how to implement a simple basic authentication login with Swift. The first screen of my app is a simple form with text fields (username and password) and a Sign In button. In my LoginViewController.swift file I linked the button to this: @IBAction func doLogin(sender : AnyObject) { } The probem now is that I don't know how to go on. I have a local server in MAMP where there is this file.php querying a database and which works perfectly: <?php $deep=""; require_once($deep."class/config.php"); $sistema = new config($deep); if( isset($_GET["username"]) && isset($_GET["password"]) ) { $username=mysqli_real_escape_string

Cites Fadeef Saleh · 2016-01 · Stack Overflow · on “how can i fix this error when i try to Using External Database and API's with swift”

i try to using external database and api's. so i follow from this video in youtube [this video] and i see this error "Value of optional type 'NSURL?' not unwrapped; " on that line func request(url:String,callback:(NSDictionary)->()) { var nsURL = NSURL(string: url) ///////////////////////////on this line///////////////////////////////// let task = NSURLSession.sharedSession().dataTaskWithURL(nsURL) { ///////////////////////////////////////////////////////////////// (data,response,error) in var error:NSError? var response = NSJSONSerialization.JSONObjectWithData(data, options:NSJSONReadingOptions.MutableContainers, error: error) as NSDictionary callback(response) } task.resume() } and when i try t