13. 存在しないURLに接続しようとした
didFailWithError:が呼び出される
エラーは「サーバが見つからない」
urlString = http://msyk1234.dyndns.org/
Calling: connection:willSendRequest:redirectResponse: (null)
Calling: connectionShouldUseCredentialStorage:
Calling: connection:didFailWithError: Error Domain=NSURLErrorDomain
Code=-1003 "A server with the specified hostname could not be found."
UserInfo=0x7013250 {NSErrorFailingURLStringKey=http://
msyk1234.dyndns.org/, NSErrorFailingURLKey=http://
msyk1234.dyndns.org/, NSLocalizedDescription=A server with the specified
hostname could not be found., NSUnderlyingError=0x7013190 "A server
with the specified hostname could not be found."}
13
16. すべてのネットワーク接続がオフ(1)
didFailWithError:が呼び出される
エラーは「インターネットがオフライン」
urlString = http://msyk.dyndns.org/
Calling: connection:willSendRequest:redirectResponse: (null)
Calling: connectionShouldUseCredentialStorage:
Calling: connection:didFailWithError: Error Domain=NSURLErrorDomain
Code=-1009 "The Internet connection appears to be offline."
UserInfo=0x4b34070 {NSErrorFailingURLStringKey=http://msyk.dyndns.org/,
NSErrorFailingURLKey=http://msyk.dyndns.org/,
NSLocalizedDescription=The Internet connection appears to be offline.,
NSUnderlyingError=0x4b0dbe0 "The Internet connection appears to be
offline."}
16
17. すべてのネットワーク接続がオフ(2)
URLにIPアドレスを指定した場合
didFailWithError:が呼び出される
エラーは「サーバに接続できない」
urlString = http://10.0.1.1/
Calling: connection:willSendRequest:redirectResponse: (null)
Calling: connectionShouldUseCredentialStorage:
Calling: connection:didFailWithError: Error Domain=NSURLErrorDomain
Code=-1004 "Could not connect to the server." UserInfo=0x4e2fa70
{NSErrorFailingURLStringKey=http://10.0.1.1/, NSErrorFailingURLKey=http://
10.0.1.1/, NSLocalizedDescription=Could not connect to the server.,
NSUnderlyingError=0x4e0c4c0 "Could not connect to the server."}
17
24. 確認できない証明書(エラーにする場合)
SecTrustEvaluate関数の戻り値
•
kSecTrustResultRecoverableTrustFailureの場合にNOを返す
基本3メソッドではこれと同じ状態
urlString = https://coolnotify.com/
Calling: connection:willSendRequest:redirectResponse: (null)
Calling: connectionShouldUseCredentialStorage:
Calling: connection:canAuthenticateAgainstProtectionSpace: auth
method=NSURLAuthenticationMethodServerTrust/host=coolnotify.com
Calling: connection:didFailWithError: Error Domain=NSURLErrorDomain Code=-1202 "The
certificate for this server is invalid.You might be connecting to a server that is pretending to be
“coolnotify.com” which could put your confidential information at risk." UserInfo=0x4b232e0
{NSErrorFailingURLStringKey=https://coolnotify.com/, NSLocalizedRecoverySuggestion=Would
you like to connect to the server anyway?, NSErrorFailingURLKey=https://coolnotify.com/,
NSLocalizedDescription=The certificate for this server is invalid.You might be connecting to a
server that is pretending to be “coolnotify.com” which could put your confidential information
at risk., NSUnderlyingError=0x4b22c10 "The certificate for this server is invalid.You might be
connecting to a server that is pretending to be “coolnotify.com” which could put your
confidential information at risk.", NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef:
24