什么时候该用ASIHTTPRequest,什么时候该用ASIFormDataRequest怎么判断
1、
NSString *postURL = [NSStringstringWithFormat:@"http://xxxxxx.php?model=%@&data=%@", myModel, myAllData];
NSLog(@"发送注册请求URL:%@", postURL);
ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:postURL]];
[request startSynchronous];
2、
NSString *postURL = [NSStringstringWithFormat:@"http://xxxxxx.php"];
ASIFormDataRequest *request = [[ASIFormDataRequestalloc] initWithURL:[NSURLURLWithString:postURL]];
[request addPostValue:myModel forKey:@"model"];
[request addPostValue:myAllData forKey:@"data"];
[request startSynchronous];
发送一个注册请求,为什么用1的写法直接执行if([request error]),用2就执行if(![request error])啊????
什么时候该用ASIHTTPRequest,什么时候该用ASIFormDataRequest怎么判断啊???
==========================================================================
1. 如果是 Get ,或者参数可以简单的组成 Get 方式提交的时候, 比如 thread.php?id=123 , 就用 ASIHTTPRequest 就可以了
原因是简单
2. 如果必须是 POST ,或者参数很多,你要构造一个带参数的 URL 很麻烦的时候,就用 ASIHttpFormDataRequest