Re: [問題] 有人在用ASIHTTPRequest嗎?

看板MacDev作者 (肉元,吉米,助教)時間14年前 (2011/03/23 12:22), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
※ 引述《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
文章代碼(AID): #1DYNMYPu (MacDev)
文章代碼(AID): #1DYNMYPu (MacDev)