Wen/bison (author of Jane's book)
Original link: http://www.jianshu.com/p/dd71e15df5d0
Copyright belongs to the author, please contact the author to obtain authorization, and Mark "book author".
The first part, the configuration item
In this only talk about the pure hand to play the third-party framework of the method, Pods the self-Baidu Oh! If you don't know Pods , you can click Transfer.
Transmission Door
First we create a project such as
53b9d04d-d5e8-47b1-b43d-7bdcb5a89a61.png
Then put all the downloaded Alamofire unzip files into the created project folder, as
377c9004-df60-4079-9aeb-9faea25a6e60.png
The key moment is up oh, concentrate, attention!!!
F2b13b31-604e-47ab-93db-d01e17fbaf73.png
After this figure, is the most important time, please watch the red box part, do not choose the wrong Oh!!!
08b18da3-69f7-4b34-9e52-1a1b76e87c11.png
Then we will Alamofire add the static library to the project, the specific operation such as
217f03bd-7c5f-42a2-be61-e709d3917d53.png
Then, we import Alamofire the header file, run, see if the error, do not error, we import the file configuration project is right!
Ps
Tell everyone a little secret, bison found that a lot of third-party frameworks are imported this way Oh! For exampleHanekeSwift
The second part, Bison teaches you how to useAlamofire
On the Internet casually find an interface, as a demonstration of this tutorial, the specific code is as follows
ImportUIKitImportAlamofireClassViewcontroller:Uiviewcontroller {LetBaiduurl ="Http://apis.haoservice.com/lifeservice/cook/query?"OverrideFuncViewdidload() {Super.viewdidload ()Network requestsSelf. Reloaddata ()}FuncReloaddata(){Let parameters = ["Menu":"Potatoes","PN":1,"RN":"10","Key":"2ba215a3f83b4b898d0f6fdca4e16c7c",]Alamofire.request (.POST,Baiduurl, parameters:parameters). Responsejson {ResponseInchDebugPrint (response)Switch Response.result {case. success: //convert the resulting JSON data into a dictionary if let j = response.result.value as? nsdictionary{//gets the key in the dictionary as an array let Span class= "hljs-type" >items = J.valueforkey ( "result") as! Span class= "Hljs-type" >nsarray //convenient array get every dictionary model for dict in items{print (Dict)}} case. failure (let error): print (Error)} } }}
To this end of our tutorial, there are any questions can leave a message Oh! Will take the time to answer your questions.
IOS Development--Add engineering