iOS網絡post請求

jopen 9年前發布 | 1K 次閱讀 Objective-C IOS

// post請求(代理方式)

// NSURL * url = [NSURL URLWithString:@"http://192.168.2.162/logo.php"];

//

// //通過URL建立請求對象

// NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL:url];

//

// //設置請求方式(默認的是get方式)

// request.HTTPMethod = @"POST";//使用大寫規范

//

// //設置請求參數

//// NSString * str = @"userName=jereh&pwd=123";

// NSString * str = @"test2.rar";

// request.HTTPBody = [str dataUsingEncoding:NSUTF8StringEncoding];

//

// //創建NSURLConnection 對象用來連接服務器并且發送請求

// NSURLConnection * conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];

// [conn start];

// NSLog(@"%@", [NSThread currentThread]); </pre>

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!