iOS asihttp nslog请求

时间:2011-12-08 05:15:11

标签: iphone ios asihttprequest nslog

我需要记录ASIHTTP中使用的请求

   NSURL *url = [NSURL URLWithString:@"https:// tor.or rd.net.au/OnlineService.svc/JSON/G "];

    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

    [request setDelegate:self];

    [request setPostValue:@"b07db55065b922fdae9" forKey:@"token"];
    [request setPostValue:@"2312" forKey:@"points"];

    [request startSynchronous];
    //hasta aqui!
    NSString *response = [request responseString];

    NSLog(@"the request ::%@", request );

    NSLog(@"respond ::%@", response);

但我在我的nslog中得到了这个

     the request ::<ASIFormDataRequest: 0x7b62a00>

我想看到网址和正文(字典)

那么如何格式化要记录的响应, 谢谢!

3 个答案:

答案 0 :(得分:3)

ASIFormDataRequestASIHTTPRequest的子类,

要查看网址,请使用NSLog(@"the request ::%@", [request originalURL]);

答案 1 :(得分:2)

几天前我也有同样的问题。想出来了,这是解决方案:

转到ASIHTTPRequestConfig.h文件并查找第20行。它将是

 // When set to 1, ASIFormDataRequests will print information about the request body to the console 
#ifndef DEBUG_FORM_DATA_REQUEST
#define DEBUG_FORM_DATA_REQUEST 0
#endif

因此,要记录请求正文,只需将0更改为1.所以就像那样:

 // When set to 1, ASIFormDataRequests will print information about the request body to the console 
#ifndef DEBUG_FORM_DATA_REQUEST
#define DEBUG_FORM_DATA_REQUEST 1
#endif

享受。希望它有所帮助:)

答案 2 :(得分:1)

这是请求。它是指向请求对象的指针的日志。你还在寻找什么?

相关问题