/**
認証 iOS8からメソッド変更
**/
- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
//basic認証のid,passを求められたら
//root.plistからbasic認証のユーザー、パスワードを取得
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSString* basic_UserId = [userDefaults stringForKey: @"basic_id"];
NSString* basic_Password = [userDefaults stringForKey: @"basic_pass"];
if ([challenge previousFailureCount] == 0) {
NSURLCredential *newCredential = [NSURLCredential credentialWithUser:basic_id
password:basic_pass
persistence:NSURLCredentialPersistenceForSession];
[[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];
}else {
//認証失敗
NSLog(@"failure");
}
}