- (void)jsonRequestSerial
{
NSURLRequest *request=[NSURLRequestrequestWithURL:[NSURLURLWithString:@"http://192.168.0.124:8080/WYServer/login?user=1222&pwd=kj"]];
NSData *data=[NSURLConnectionsendSynchronousRequest:request returningResponse:nilerror:nil];
NSDictionary *dict=[NSJSONSerializationJSONObjectWithData:data options:NSJSONReadingAllowFragmentserror:nil];
if (dict[@"error"]) {
NSLog(@"%@",dict[@"error"]);
}
else
{
NSLog(@"%@",dict[@"%@"]);
}
}
- (void) getAsyn
{
NSURL *url=[NSURLURLWithString:@"http://192.168.0.124:8080/WYServer/login?username=333zc&pwd=w444"];
NSURLRequest *request=[NSURLRequestrequestWithURL:url];
[NSURLConnectionsendAsynchronousRequest:request queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response,NSData *data, NSError *connectionError) {
NSLog(@"Response=%@",response);
NSDictionary *dict=[NSJSONSerializationJSONObjectWithData:data options:NSJSONReadingAllowFragmentserror:nil];
if (dict[@"error"]) {
NSLog(@"%@",dict[@"error"]);
}
else
{
NSLog(@"%@",dict[@"success"]);
}
}];
}
- (void)postAsyn
{
NSURL *url=[NSURLURLWithString:@"http://192.168.0.124:8080/WYServer/login"];
NSMutableURLRequest *mutRequest=[NSMutableURLRequestrequestWithURL:url];
mutRequest.HTTPMethod=@"POST";
NSString *str=@"username=wxxc&pwd=w11";
mutRequest.HTTPBody=[strdataUsingEncoding:NSUTF8StringEncoding];
[NSURLConnectionsendAsynchronousRequest:mutRequest queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response,NSData *data, NSError *connectionError) {
NSLog(@"Response=%@",response);
NSDictionary *dict=[NSJSONSerializationJSONObjectWithData:data options:NSJSONReadingAllowFragmentserror:nil];
if (dict[@"error"]) {
NSLog(@"%@",dict[@"error"]);
}
else
{
NSLog(@"%@",dict[@"success"]);
}
}];
}