iOS開発で、Laravelと組み合わせて、Alamofireを使用して通信してみる。
Podfile
pod 'Alamofire', '4.8.2'
サーバーサイドへ
http://bbsystem.local:8000/analysis/getData/1001/2020/2
をリクエストすると、以下のJSON返却
簡易サーバーを使用している場合、以下で起動
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>

