Skip to content

CountableRange is deprecated, renamed to Range #1432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Foundation/NSArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ open class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
return
}

objects += range.toCountableRange()!.map { self[$0] }
objects += Range(range)!.map { self[$0] }
}

open func index(of anObject: Any) -> Int {
Expand Down Expand Up @@ -874,7 +874,7 @@ open class NSMutableArray : NSArray {
if type(of: self) === NSMutableArray.self {
_storage.removeSubrange(Range(range)!)
} else {
for idx in range.toCountableRange()!.reversed() {
for idx in Range(range)!.reversed() {
removeObject(at: idx)
}
}
Expand Down
6 changes: 3 additions & 3 deletions Foundation/NSOrderedSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ extension NSOrderedSet {
public convenience init(array set: [Any], range: NSRange, copyItems flag: Bool) {
var objects = set

if let range = range.toCountableRange(), range.count != set.count || flag {
if let range = Range(range), range.count != set.count || flag {
objects = [Any]()
for index in range.indices {
let object = set[index]
Expand Down Expand Up @@ -461,7 +461,7 @@ extension NSMutableOrderedSet {
}

open func replaceObjects(in range: NSRange, with objects: UnsafePointer<AnyObject>!, count: Int) {
if let range = range.toCountableRange() {
if let range = Range(range) {
let buffer = UnsafeBufferPointer(start: objects, count: count)
for (indexLocation, index) in range.indices.lazy.reversed().enumerated() {
let object = buffer[indexLocation]
Expand All @@ -478,7 +478,7 @@ extension NSMutableOrderedSet {
}

open func removeObjects(in range: NSRange) {
if let range = range.toCountableRange() {
if let range = Range(range) {
for index in range.indices.lazy.reversed() {
removeObject(at: index)
}
Expand Down
5 changes: 0 additions & 5 deletions Foundation/NSRange.swift
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,6 @@ extension NSRange {
location = x.lowerBound
length = x.count
}

internal func toCountableRange() -> Range<Int>? {
if location == NSNotFound { return nil }
return location..<(location+length)
}
}

extension NSRange: NSSpecialValueCoding {
Expand Down
Loading