iPhone URL 讀取操作

2021-05-27 11:07:40 字數 2669 閱讀 2009

操作類

nsurl 

nsurlrequest  與  nsurlresponse 

nsurlconnection : 同步訪問和非同步訪問

非同步訪問例項:

// 傳送url

nsstring

// 傳送引數

];

// 收到響應時, 會觸發
-

(void

)connection:(

nsurlconnection

*)aconnection didreceiveresponse:(

nsurlresponse

*)aresponse;

// 你可以在裡面判斷返回結果, 或者處理返回的http頭中的資訊
// 資料接收
-

(void

)connection:(

nsurlconnection

*)aconn didreceivedata:(

nsdata*)

data

// 網路錯誤時觸發
-

(void

)connection:(

nsurlconnection

*)aconn didfailwitherror:(

nserror*)

error;

// 全部資料接收完畢時觸發
-

(void

)connectiondidfinishloading:(

nsurlconnection

*)aconn;

iphone URL重定向問題

如何獲得重定向的 stackoverflow 上有相同的問題。他的 nsurl originalurl nsurl urlwithstring nsdata data nil nsmutableurlrequest request nsmutableurlrequest requestwithurl...

xml操作讀取

xml檔案讀取可以是讀取外部 xml檔案,也可以是讀取xml格式的字串。使用load和loadxml函式來做讀取操作。如下 string xml 111111 33333 44444 xmldocument doc new xmldocument doc.loadxml xml httpcontex...

讀取檔案操作

獲取路徑 nsstring path nsbundle mainbundle pathforresource file3 oftype dmh nslog path path 轉換 unsigned int lenofstrvalue path length char szvalue lenofst...