標籤:style blog http color os io 使用 ar for
1 //1、 2 NSString *postURL = [NSString stringWithFormat:@"http://xxxxxx.php?model=%@&data=%@", myModel, myAllData]; 3 NSLog(@"發送註冊請求URL:%@", postURL); 4 ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:postURL]]; 5 [request startSynchronous]; 6 7 8 //2、 9 NSString *postURL = [NSString stringWithFormat:@"http://xxxxxx.php"];10 ASIFormDataRequest *request = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:postURL]];11 [request addPostValue:myModel forKey:@"model"];12 [request addPostValue:myAllData forKey:@"data"];13 [request startSynchronous];
1. 如果是 Get ,或者參數可以簡單的組成 Get 方式提交的時候, 比如 thread.php?id=123 , 就用 ASIHTTPRequest 就可以了,原因是簡單
2. 如果必須是 POST ,或者參數很多,你要構造一個帶參數的 URL 很麻煩的時候,就用 ASIHttpFormDataRequest
一般建議使用post請求,因為這樣不會將你的參數暴露在url上,不過手機用戶端使用哪一種都可以。
【IOS】ASIHTTPRequest,ASIFormDataRequest