Swift Package Index


Safe Collection for Swift


  • The latest stable release is 3.1.0. Released almost 2 years ago.
  • The last commit to master was almost 2 years ago.

Swift Version Compatibility

  • 3.1.0 and master
    5.3
    5.2
    5.1
    5.0
    4.2
Full build results

Platform Compatibility

  • 3.1.0 and master
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
Full build results

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.