SwiftからAlamofireを使う
Alamofireの作業ログ、何点かハマるポイントがあったのでその記録。
httpファイルにアクセスできない
https://以外のhttpのアクセスは制限されています。
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be >configured via your app's Info.plist file.
NSAppTransportSecurityのkeyを追加する必要がありました。追加して無事OK。
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
localホストにアクセスできない。
Alamofireからlocalhostに接続できずにハマる。
stackoverflowにありました。 stackoverflow.com
要点としては、この記述ではアクセスできませんでした。
let url = "http://localhost:8080/"
以下のように変更してOK.
let url = "http://0.0.0.0:8080/post/1"
Test時には、expectationWithDescriptionを使う必要がある。
let expectation = expectationWithDescription("scync")