Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.
/ Nodes Public archive

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

License

Notifications You must be signed in to change notification settings

ml-archive/Nodes

Repository files navigation

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published