简体   繁体   English

休息,杰森,Alamofire-迅捷

[英]Rest, Json, Alamofire - Swift

I have really huge problem with these 3. I can't them distinct. 我对这三项确实有很大的疑问。我无法将它们区分开。 I know that are libraries and cooperate with themselves . 我知道那是图书馆,并与他们合作。 It seems to me that all three make the same , I mean retrieve data from Internet. 在我看来这三个都一样,我的意思是从Internet检索数据。 Could you explain me what's going on with these three? 您能解释一下这三个发生了什么吗?

REST(Representational state transfer): It is a framework which provides you a way of communicating between computers using internet. REST(表示状态传输):这是一个框架,为您提供了一种使用Internet在计算机之间进行通信的方法。 Typically, over an API call. 通常,通过API调用。 It consists of an Architecture with 6 Constraints (5 Compulsory & 1 Optional). 它由具有6个约束(5个强制性和1个可选)的体系结构组成。 Read more about it here . 在此处了解更多信息。

JSON(JavaScript Object Notation): This is a standard representation of data exchange. JSON(JavaScript对象表示法):这是数据交换的标准表示。 There are other representations like XML which were used for the same. 还有其他用于XML的表示形式。 JSON consists of basic data structures in order to pass data over network. JSON由基本数据结构组成,以便通过网络传递数据。 It uses String, Number, Array, another JSON Object, null and a Boolean to efficiently represent data. 它使用字符串,数字,数组,另一个JSON对象,空值和布尔值来有效地表示数据。

The above 2 concepts are relevant in any stream or language of computer science. 以上两个概念与计算机科学的任何流或语言有关。

Alamofire(HTTP Networking library for Swift): This library IS ONLY USED IN iOS APPS WITH SWIFT. Alamofire(用于Swift的HTTP网络库):该库仅在带有SWIFT的iOS应用中使用。 It doesn't hold relevance outside this subset. 它在此子集之外不具有相关性。 Sure, there is a method of making network calls without using Alamofire in swift. 当然,有一种无需快速使用Alamofire即可进行网络通话的方法。 You can read about NSURL, NSURLSession etc. to learn the classic method. 您可以阅读有关NSURL,NSURLSession等的内容,以学习经典方法。 The problem with normal NSURL calls is that it is very elaborate to write those calls and can get messy in no time. 普通NSURL调用的问题在于编写这些调用非常复杂,并且很快就会变得混乱。 Thankfully, there is a way of mitigating that mess. 值得庆幸的是,有一种缓解这种混乱的方法。 Alamofire handles those async calls efficiently and also lets you do cool stuff with the response easily. Alamofire有效地处理了这些异步调用,还使您可以轻松地通过响应来完成一些很酷的事情。

NOTE: These 3 are not at all same. 注意:这3个不完全相同。 REST calls can be made using JSON, XML, URL Encoding etc. JSON can be used in normal JavaScript and not necessarily needs to be passed over a network. 可以使用JSON,XML,URL编码等进行REST调用。JSON可以在常规JavaScript中使用,不一定需要通过网络传递。 and Alamofire exists to just ease the pain of making network calls in iOS. Alamofire的存在只是为了缓解在iOS中进行网络通话的痛苦。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM