CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

SafeIndex 2.0.0

SafeIndex 2.0.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Dec 2017
SwiftSwift Version 4.0
SPMSupports SPM

Maintained by Suyeol Jeon.



SafeIndex 2.0.0

  • By
  • Suyeol Jeon




Optional Index for Swift.

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 'SafeIndex'
  • For iOS 8+ projects with Carthage:

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

    import PackageDescription
    
    let package = Package(
      name: "MyAwesomeApp",
      dependencies: [
        .package(url: "https://github.com/devxoul/SafeIndex", "1.0.0"),
      ]
    )

License

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