天天看點

用 AFNetworking 通過 POST 方式發送資料

afnetworking 版本為 2.0.2

post 發送資料有兩種形式:

1、發送純文字的内容

2、發送的 body 部分帶有檔案(圖檔,音頻或者其他二進制資料)

對應的 content-type 有兩種:

1、application/x-www-form-urlencoded

2、multipart/form-data

傳統的使用 post 的方式發送資料用于上傳檔案,afnetworking 中提供了直接的接口:

使用 post 方式發送純文字内容:

其中 self.manager 為 afhttprequestoperationmanager 執行個體。