EFSafeArray is an extension to make Array subscript safe.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Assets Update .travis.yml Nov 6, 2018
EFSafeArray Insert license head Oct 1, 2017
Example 4.1.0 Nov 6, 2018
.gitattributes 0.0.1 Jul 28, 2017
.gitignore Initial commit Jul 28, 2017
.swift-version Swift 4.2 Nov 6, 2018
.travis.yml
CHANGELOG.md 4.1.0 Nov 6, 2018
CODE_OF_CONDUCT.md Add CODE_OF_CONDUCT.md Oct 1, 2017
CONTRIBUTING.md Add CONTRIBUTING.md Oct 1, 2017
EFSafeArray.podspec
ISSUE_TEMPLATE.md
LICENSE
README.md Update README.md Feb 2, 2019
_Pods.xcodeproj
_config.yml Set theme jekyll-theme-cayman Oct 1, 2017

README.md

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Version Needs
0.x XCode 8.0+
Swift 3.0+
iOS 8.0+
4.x XCode 9.0+
Swift 4.0+
iOS 8.0+

Installation

EFSafeArray is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'EFSafeArray'

Use

var list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
// Get Index
let xxx = list[0]               // xxx: Int = 1
let zzz = list[0~]              // zzz: Int? = 1
let yyy = list[10~]             // yyy: Int? = nil

// Set Index
list[0] = 0                     // list = [0, 2, 3, 4, 5, 6, 7, 8, 9, 0]
list[0~] = 1                    // list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
list[10~] = 10                  // list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]

// Get Bounds
let iiii = list[(0...5)~]       // iiii: ArraySlice<Int>? = [1, 2, 3, 4, 5, 6]
let oooo = list[(-1...12)~]     // oooo: ArraySlice<Int>? = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]

// Set Bounds
list[(0...5)~] = [1]            // list = [1, 7, 8, 9, 0]
list[(-1...12)~] = [2, 3, 4, 5] // list = [2, 3, 4, 5]

Author

EyreFree, eyrefree@eyrefree.org

License

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