2016-06-27 3 views
-1

トップ10のユーザープロファイルが名前、年齢、都市および距離と共に表示される私のアプリケーション用のページを作成しました。現在、私のページには、この目的のためのNSURL接続

current page

のように見えると私はPOST method.whereパス、名前、年齢を使用するように求めてきました。このため、この

page need to be like this

のように表示する必要が、都市と距離を表示する必要があります。

誰でもNSURL接続についてわからないので、ウェブサービスを利用する方法を教えてください。親切に助けてください!

+1

あなたがしようとしているでしょうか?。 SOを最初に検索してください。あなたは非常に多くの答えを得るでしょう。あなたがいなくなったら、質問を投稿してください。 – Signare

+2

友達リストにgoogleを追加:) :) ... https://www.google.co.in/search?q=call+webservice+ios&ie=utf-8&oe=utf-8&client=firefox-b-ab&gfe_rd=cr&ei= EgtxV6q-ApDT8gfBm46QDg#q = call + webservice + ios + objc –

+0

これを参照してください - http://codewithchris.com/tutorial-how-to-use-ios-nsurlconnection-by-example/ – Signare

答えて

0
This code may be help you 
Add NSURLConnectionDelegate delegate 
@interface YourViewController : UIViewController<NSURLConnectionDelegate> 

And some where in function in same interface 
// Send a synchronous request 
NSURLRequest * urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com"]]; 

NSURLResponse * response = nil; 

NSError * error = nil; 

NSData * data = [NSURLConnection sendSynchronousRequest:urlRequest 
              returningResponse:&response 
                 error:&error]; 

if (error == nil) { 
    // Parse data here 
} 
And for more this link help you 
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html 
+0

'sendSynchronousRequest'は推奨されなくなりました.Appleはとにかに同期ネットワーキングの使用を強く推奨していません。 – vadian

+0

OK、直接appleのdocリンクを使用してください – user3833693

0
  • インポートAFNetworking 3.0プロジェクトに、次の方法を試してください。

    NSString *urlString = @"https://www.example.com/info 
    
    NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init]; 
    //add parameters to dictionary 
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; 
    
    [manager POST:urlString parameters:parameters progress:nil 
    success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { 
    
    
         NSLog(@"%@", responseObject);//you have to parse this object 
    
        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { 
    
    }]; 
    
関連する問題