TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Oct 2017 |
SwiftSwift Version | 4.0 |
SPMSupports SPM | ✗ |
Maintained by Brian Murphy.
To run the example project, clone the repo, and run pod install
from the Example directory first.
Use the IceAndFireRequestEngine
singleton to perform requests to fetch data for single objects or for a list of objects.
Pass in an id
and specify the return type in the completion handler to fetch an object.
Example:
var houseObject : IceAndFireHouse?
IceAndFireRequestEngine.sharedInstance.fetchIceAndFireObject(1) { (iceAndFireObject : IceAndFireHouse?, error : NSError?) -> Void in
houseObject = iceAndFireObject
}
Fetches a page of objects from the API. Optional page and limit is used within the request for pagination. ResponseType is defined within the completionHandler
Example:
var charactersArray : [IceAndFireCharacter]?
IceAndFireRequestEngine.sharedInstance.fetchIceAndFireObjectsWithPage(2, limit: 10) { (iceAndFireObjects : [IceAndFireCharacter]?, error : NSError?) -> Void in
charactersArray = iceAndFireObjects
}
Populates a basic object using its resource URL. All objects returned from an API can contain other resource URLs. These objects are parsed into its specific type and its url popluated. This means you have a simple way to populate each of the "minified" objects
Example:
var book = IceAndFireBook(urlString: "http://anapioficeandfire.com/api/books/2")
IceAndFireRequestEngine.sharedInstance.fetchIceAndFireObject(book) { (iceAndFireObject : IceAndFireBook?, error : NSError?) -> Void in
book = iceAndFireObject
}
Fetching pages will return an IceAndFireLinkHeaders
object. This can contain 4 pagination NSURLs. prev
, next
, first
and last
. They will be a reference to the appropriate page based on the keyword.
These can be used for simple pagination chaining
IceAndFireKit is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod "IceAndFireKit"
Brian, [email protected]
IceAndFireKit is available under the MIT license. See the LICENSE file for more info.