Skip to content

Collection of µ-frameworks and utility classes/extensions used in CELLULAR swift projects.

License

Notifications You must be signed in to change notification settings

benjidea/cellular-swift

 
 

Repository files navigation

CELLULAR

Build Status Codecov CocoaPods Compatible Swift Version Platform

A collection of Swift utilities that we share across swift-based projects at CELLULAR. It is a standalone module with no external dependencies.

Features

Codable

There are several extensions on KeyedDecodingContainer. Most of which are heavily inspired by Unbox.

THE PLANET

Throughout the Codable examples, the following struct is used:

import CELLULAR

public struct Planet: Codable {

    public var discoverer: String

    public var hasRingSystem: Bool

    public var numberOfMoons: Int

    public var distanceFromSun: Float // 10^6 km

    public var surfacePressure: Double? // bars

    public var atmosphericComposition: [String]

1. Allows Foundation types to be inferred on value assignment

    public init(from decoder: Decoder) throws {
	let container = try decoder.container(keyedBy: CodingKeys.self)

	discoverer = try container.decode(forKey: .discoverer) // String
	hasRingSystem = try container.decode(forKey: .hasRingSystem) // Bool
	numberOfMoons = try container.decode(forKey: .numberOfMoons) // Int
	distanceFromSun = try container.decode(forKey: .distanceFromSun) // Float

2. Even Optional holding these types may be inferred

	surfacePressure = try container.decode(forKey: .surfacePressure) // Double?

3. Allows instances in collections to fail decoding

	atmosphericComposition = try container.decode(forKey: .atmosphericComposition, allowInvalidElements: true) ?? []
    }
}

Locking

TODO

Result

A type that represents either a success value or failure value, both of which may be of different types. This is similar to Swift’s native Optional type, yet, instead of nil as error indicating, it allows none-nil failure returns with additional information.

import CELLULAR

public enum Result<Success, Failure> {
    case success(Success)
    case failure(Failure)
}

Storyboard

TODO

Requirements

  • iOS 9.3+ | watchOS 2.2+ | tvOS 9.2+ | macOS 10.10+ | Ubuntu 14.04+
  • Swift 4.0+

Installation

Once you have your Swift package set up, adding CELLULAR as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/cellular/cellular-swift.git", from: "1.0.0")
]

License

CELLULAR is released under the MIT license. See LICENSE for details.

About

Collection of µ-frameworks and utility classes/extensions used in CELLULAR swift projects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 93.1%
  • Shell 3.2%
  • Ruby 2.6%
  • Objective-C 1.1%