0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Alamofireで通信してみる。

Posted at

iOS開発で、Laravelと組み合わせて、Alamofireを使用して通信してみる。

Podfile

pod 'Alamofire', '4.8.2'

サーバーサイドへ
http://bbsystem.local:8000/analysis/getData/1001/2020/2
をリクエストすると、以下のJSON返却

スクリーンショット 2019-10-25 14.16.49.png

簡易サーバーを使用している場合、以下で起動

 php artisan serve --host 0.0.0.0
import UIKit
import Alamofire

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        Alamofire.request("http://bbsystem.local:8000/analysis/getData/1001/2020/2")
            .responseString { response in
            debugPrint("Response: \(response)")
        }
    }
}

HTTP 通信を有効にする。

info.plist
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>

確認
スクリーンショット 2019-10-25 14.26.26.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?