2016-03-22 2 views
-3

this is my screenshot [これを解決するために検索しましたが、解決策は見つかりませんでした。スクリーンショットに表示されるエラーが表示される理由私を助けてください。nsmutableurlrequestの表示されない@interfaceはセレクタsethttpbodyを宣言します

NSURL *url=[NSURL URLWithString:@"http://www.gourmet7.com/auth"]; 
    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]; 
    NSError *error = [[NSError alloc] init]; 
    NSHTTPURLResponse *response = nil; 
    NSData *urlData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; 

    NSLog(@"Response code: %ld", (long)[response statusCode]); 
       NSString *responseData = [[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding]; 

] 2

+0

iosの新機能です。私にxcode 7.2を使用している解決策を教えてください – Sandy

+0

これまでに何を試しましたか? – Genzotto

+0

投稿を投稿したい私は何が間違っていたのか分からない。 @Genzottoはあなたに私の質問をしました。 – Sandy

答えて

1

それが唯一の野生の推測できますが、あなたのコードはうまくコンパイルとして、私はあなたが8.0より低い一部のiOSバージョンをターゲットにしていると思います。

残念ながらHTTPBodyプロパティは8.0以降でのみ使用できます。したがって、最小のiOSバージョンを8.0以上にするか、別のメカニズムを使用する必要があります。

関連する問題