Swiftpack.co - Package - devxoul/SafeCollection

SafeCollection

Swift Build Status CocoaPods Carthage compatible

SafeCollection provides a safer way to deal with subscripts. Inspired by Swift's LazyCollection.

At a Glance

let arr = ["A", "B", "C"]

arr[0]    // "A"
arr[100]  // fatal error: Array index out of range 😟

arr.safe[0]   // Optional("A")
arr.safe[100] // nil 😄

Installation

  • For iOS 8+ projects with CocoaPods:

    pod 'SafeCollection'
    
  • For iOS 8+ projects with Carthage:

    github "devxoul/SafeCollection"
    
  • Using Swift Package Manager:

    import PackageDescription
    
    let package = Package(
      name: "MyAwesomeApp",
      dependencies: [
        .package(url: "https://github.com/devxoul/SafeCollection", .upToNextMajor(from: "3.0.0")),
      ]
    )
    

License

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

Github

link
Stars: 34
Help us keep the lights on

Dependencies

Used By

Total: 0

Releases

3.0.0 - Dec 26, 2017

  • Migrate to SafeCollection

2.0.0 - Nov 21, 2017

  • Update api to use safe: subscript

1.0.0 - Sep 25, 2017

  • Add support arithmetic between SafeIndex
  • Migrate to Swift 3

0.2.0 - Apr 11, 2016

  • Make it available to use SafeIndex on mutable arrays. (#1, @vhain)

0.1.0 - Feb 18, 2016

  • Hello, world!