Latest 1.4.0
Homepage https://github.com/nvzqz/OneOrMore
License MIT
Platforms ios 8.0, osx 10.9, watchos 2.0, tvos 9.0

Swift 3.0
Platforms
CocoaPods
Carthage
Swift Package Manager

A Swift collection of one or more elements.

A OneOrMore instance must have one or more elements. This makes it great for
tasks such as implementing an undo history. Chris Eidhof outlines a great
example here.

Installation

Compatibility

  • Platforms:
    • macOS 10.9+
    • iOS 8.0+
    • watchOS 2.0+
    • tvOS 9.0+
    • Linux
  • Xcode 8.0
  • Swift 3.0

Install Using Swift Package Manager

The Swift Package Manager is a
decentralized dependency manager for Swift.

  1. Add the project to your Package.swift.

    import PackageDescription
    
    let package = Package(
        name: "MyAwesomeProject",
        dependencies: [
            .Package(url: "https://github.com/nvzqz/OneOrMore.git",
                     majorVersion: 1)
        ]
    )
  2. Import the OneOrMore module.

    import OneOrMore

Install Using CocoaPods

CocoaPods is a centralized dependency manager for
Objective-C and Swift. Go here
to learn more.

  1. Add the project to your Podfile.

    use_frameworks!
    
    pod 'OneOrMore', '~> 1.0.0'

    If you want to be on the bleeding edge, replace the last line with:

    pod 'OneOrMore', :git => 'https://github.com/nvzqz/OneOrMore.git'
  2. Run pod install and open the .xcworkspace file to launch Xcode.

  3. Import the OneOrMore framework.

    import OneOrMore

Install Using Carthage

Carthage is a decentralized dependency
manager for Objective-C and Swift.

  1. Add the project to your Cartfile.

    github "nvzqz/OneOrMore"
  2. Run carthage update and follow the additional steps
    in order to add OneOrMore to your project.

  3. Import the OneOrMore framework.

    import OneOrMore

Install Manually

Simply add the OneOrMore.swift file into your project.

Usage

let numbers = OneOrMore(1, 2, 3)

Because a OneOrMore instance is guaranteed to have one or more elements,
properties such as first and last return a non-optional value.

OneOrMore has overloaded map(_:), sorted(by:), and reversed() methods
that return OneOrMore.

let multiplesOfTwo = numbers.map { $0 * 2 }  // OneOrMore<Int> [2, 4, 6]

let reversed = values.reversed()  // OneOrMore<Int> [6, 4, 2]

let sorted = reversed.sorted(by: <)  // OneOrMore<Int> [2, 4, 6]

License

OneOrMore is published under the MIT License.

Latest podspec

{
    "name": "OneOrMore",
    "version": "1.4.0",
    "summary": "A Swift collection of one or more elements.",
    "homepage": "https://github.com/nvzqz/OneOrMore",
    "license": {
        "type": "MIT",
        "file": "LICENSE.md"
    },
    "authors": "Nikolai Vazquez",
    "social_media_url": "https://twitter.com/nikolaivazquez",
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "source": {
        "git": "https://github.com/nvzqz/OneOrMore.git",
        "tag": "v1.4.0"
    },
    "source_files": "Sources/*.swift",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This