TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Dec 2017 |
SwiftSwift Version | 4.0 |
SPMSupports SPM | ✓ |
Maintained by Suyeol Jeon.
Optional Index for Swift.
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 😄
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"),
]
)
SafeIndex is under MIT license. See the LICENSE file for more info.