UI 網路程式設計

2021-06-29 15:09:32 字數 1452 閱讀 8286

什麼是網路程式設計?

為什麼要學習網路程式設計?

網路程式設計主要做什麼事情?

什麼是c/s模式?什麼又是b/s模式?跟我們有什麼關係?

client server

browser server

對於我們來說,網路程式設計難學嗎?

get 同步

get 非同步 block方式

post 同步

post 非同步 delegate實現

請求物件: nsmutableurlrequest

如果需要資料

0. 準備nsurl

1. 建立請求物件

設定請求方式:get、post

如果選擇了post方式,設定請求資料

2. 建立鏈結物件並傳送請求

使用同步方式或者非同步方式

//#pragma mark - get同步

- (ibaction)getsyncbuttonaction:(uibutton *)sender

//#pragma mark - get非同步

- (ibaction)getasyncbuttonaction:(uibutton *)sender];}

//#pragma mark - post同步

- (ibaction)postsyncbuttonaction:(uibutton *)sender

//#pragma mark - post非同步

- (ibaction)postasyncbuttonaction:(uibutton *)sender

//#pragma mark - nsurlconnectiondatadelegate

//#pragma mark 開始接受請求結果

- (void)connection:(nsurlconnection *)connection didreceiveresponse:(nsurlresponse *)response

//#pragma mark 開始接受資料

- (void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data

///#pragma mark 資料接收完畢

- (void)connectiondidfinishloading:(nsurlconnection *)connection

//#pragma mark 發生錯誤,執行此方法

- (void)connection:(nsurlconnection *)connection didfailwitherror:(nserror *)error

//#pragma mark - 清除

- (ibaction)clearbuttonaction:(uibutton *)sender

UI 網路程式設計

網路請求方式分為兩種方法 get post。get和post的區別及共同點 1.客戶端到底寫 get還是 post,跟伺服器有關 後期開發時 回合伺服器開發人員一起開發 到時候客戶端開發人員需要詢問伺服器相關介面是 get還是 post 2.不管是什麼樣的請求方式,都可以進行一步連線 獲得伺服器所返...

UI 網路編輯

http超文字傳輸協議 應用層協議,由請求和響應構成,是乙個標準的客戶端伺服器,是一種無狀態協議 兩台計算機之間進行通訊所必須共同遵守的規定和規則,共同遵守.靈活 http允許傳輸任意型別的資料物件。正在傳輸的型別由content type加以標記。無連線 無連線的含義是限制每次連線只處理乙個請求。...

UI程式設計 UILabel及其屬性

ui01 uilabel created by dllo on 15 7 10.end self.window uiwindow alloc initwithframe uiscreen mainscreen bounds self.window.backgroundcolor uicolor wh...