私は目的Cで新しく、iOS 9 Xcode 7.2を使用してこの警告を出しています。 "initWithRequest:delegate: deprecated:iOS 9.0で非推奨になったもの - NSURLSession(NSURLSession.hを参照)を使用して解決する方法。私のコードは以下の通りです。'initWithRequest:delegate:'は廃止されました:iOS 9.0では廃止予定です - NSURLSessionを使用してください(NSURLSession.hを参照してください)
+(id)createGetConnectionWithName:(NSString*)strConnectionName_
withUrl:(NSString *)pageUrl
parameterNames:(NSArray *)arrParamNames
parameterValues:(NSArray *)arrParamValues
delegate:(id)delegate
{
NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:@"%@",pageUrl]];
NSMutableString *post =[NSMutableString string];
for(int i=0;i<[arrParamNames count];i++)
{
if(i==[arrParamNames count]-1)
{
[post appendFormat:@"%@=%@",[arrParamNames objectAtIndex:i],
[arrParamValues objectAtIndex:i]];
}
else
{
[post appendFormat:@"%@=%@&",[arrParamNames objectAtIndex:i],
[arrParamValues objectAtIndex:i]];
}
}
// if(![strConnectionName_ isEqualToString:APP_AUTH_CODE_NAME])
// [post appendFormat:@"&Key=%@",[self getAuthCode]];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
// conn =[[NSURLConnection alloc] initWithRequest:request delegate:self] ;
return [[self alloc] initWithRequest:request delegate:delegate];
}
ありがとうございます。
[NsurlConnection initWithRequestは重複している可能性があります](http://stackoverflow.com/questions/32647138/nsurlconnection-initwithrequest-is-deprecated) – vadian