SafeIndex 2.0.0

SafeIndex 2.0.0

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

Maintained by Suyeol Jeon.


Downloads

Total17,890
Week999
Month4,141

Installs

Apps16
Apps WeekApps This Week 9
Test Targets6
Test WeekTests This week 3
powered by Segment

GitHub

Stars22
Watchers1
Forks1
Issues0
Contributors2
Pull Requests0

Code

Files1
LOCLines of Code 20


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.