作者Gsus (肉元,吉米,助教)
看板MacDev
标题Re: [问题] 有人在用ASIHTTPRequest吗?
时间Wed Mar 23 12:22:55 2011
※ 引述《takuro1026 (呆牙)》之铭言:
: ※ 引述《Gsus (肉元,吉米,助教)》之铭言:
: : 我是用[request startAsychronous]来取得json
: : 照理来说会在requestFinished:(ASIHTTPRequest *)request {...}
: : 中可取得request.responseString & request.responseData
: : 通常是直接取得request.responseString用json parser转乘cocoa object
: : 但是现在都只得到空字串与空data
: : 而在request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data {...}
: : 中有data,用[[NSString alloc] initWithData] print出来确实可以看到json
: : 另我不解的是为什麽会跑到receivedData那边去
: : 而且更不解为什麽request.responseData却没东西...
: : 以前我也是这样用没问题说...
: 最近刚好有用到
: 在requestFinished里
: 透过[resquest responseString];
: 可以取得NSString
: 这几天这样用都是OK的
知道为什麽了
在这边po一下以免之後有人有相同问题
文件上是这样说的:
"If you need to process the response as it comes in
(for example, you want to use a streaming parser to
parse the response while it is still being downloaded),
have your delegate implement request:didReceiveData:
(see ASIHTTPRequestDelegate.h.
Note that when you do this, ASIHTTPRequest will not populate
responseData or write the response to downloadDestinationPath -
you must store the response yourself if you need to."
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 111.248.16.151