nodes-ios / Nodes

A collection of functions and data types common to how we do things at Nodes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This library has been deprecated and the repo has been archived.

The code is still here and you can still clone it, however the library will not receive any more updates or support.

NodesKit

This repository is a collection of extensions, snippets and tweaks we commonly use at Nodes.

Plaforms Carthage Compatible GitHub license

πŸ“ Requirements

  • iOS 8.0+
  • Swift 2.0+

πŸ“¦ Installation

Carthage

github "nodes-ios/Nodes" ~> 2.0

Last versions compatible with lower Swift versions:

Swift 3.1
github "nodes-ios/Nodes" == 1.0.2

Swift 3.0
github "nodes-ios/Nodes" == 1.0.0

Swift 2.3
github "nodes-ios/Nodes" == 0.2.5

Swift 2.2
github "nodes-ios/Nodes" == 0.2.2

πŸ”§ Setup

  1. Add the framework to your project
  2. Put it inside the Embedded Binaries section on your target settings

πŸ’» Usage

Default Unwrapper

This framework contains an unwrapper to be used with Serializable's extension for Alamofire. It then automatically extracts data from the response using the same pattern we commonly use in our API's.

You however need to manually set this unwrapper on the Parser inside Serializable. Best place to do this is in your AppDelegate.

import Serpent
import Nodes

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// ...
Parser.defaultUnwrapper = unwrapper()
// ...
}

Paginated Response

To have easier access to pagination information from the API we provide a PaginatedResponse struct, which can be used instead Alamofire's native Response. Implementation is simple:

func fetchInformationFromAPI(completion: PaginatedResponse<Information, NSError> -> Void) {}

You can then access the pagination information in the callback like this:

// ...

fetchInformationFromAPI(completion: { response in 
	switch response.result {
	case .Success(let object):
		print(object.data) // Your model, in this case `Information`
		print(object.meta.paginator) // The meta (paginator) data
		break
	default: break
	}
})

// ...

πŸ‘₯ Credits

Made with ❀️ at Nodes.

πŸ“„ License

Nodes is available under the MIT license. See the LICENSE file for more info.

About

A collection of functions and data types common to how we do things at Nodes.

License:MIT License


Languages

Language:Swift 88.2%Language:Objective-C 11.8%