One Logo Pool Ball
System · IOS API REFERENCE

FilePath.ComponentView

struct · iOS 15.0+ · SDK 27.1

struct ComponentView

A bidirectional, range replaceable collection of the non-root components that make up a file path. ComponentView provides access to standard `BidirectionalCollection` algorithms for accessing components from the front or back, as well as standard `RangeReplaceableCollection` algorithms for modifying the file path using component or range of components granularity. Example: var path: FilePath = "/./home/./username/scripts/./tree" let scriptIdx = path.components.lastIndex(of: "scripts")! path.components.insert("bin", at: scriptIdx) // path is "/./home/./username/bin/scripts/./tree" path.components.removeAll { $0.kind == .currentDirectory } // path is "/home/username/bin/scripts/tree"

Members (7)

get · iOS 15.0+

startIndex

TypeScript
get startIndex(): FilePath_ComponentView_Index
Swift declaration
var startIndex: FilePath.ComponentView.Index { get }

The position of the first element in a nonempty collection. If the collection is empty, `startIndex` is equal to `endIndex`.

method · iOS 15.0+

replaceSubrange

TypeScript
replaceSubrange(subrange: SDKHandle, newElements: Array<FilePath_Component>): void
Swift declaration
mutating func replaceSubrange<C>(_ subrange: Range<FilePath.ComponentView.Index>, with newElements: C) where C : Collection, C.Element == FilePath.Component

Replaces the specified subrange of elements with the given collection. This method has the effect of removing the specified range of elements from the collection and inserting the new elements at the same location. The number of new elements need not match the number of elements being removed. In this example, three elements in the middle of an array of integers are replaced by the five elements of a `Repeated<Int>` instance. var nums = [10, 20, 30, 40, 50] nums.replaceSubrange(1...3, with: repeatElement(1, count: 5)) print(nums) // Prints "[10, 1, 1, 1, 1, 1, 50]" If you pass a zero-length range as the `subrange` parameter, this method inserts the elements of `newElements` at `subrange.startIndex`. Calling the `insert(contentsOf:at:)` method instead is preferred. Likewise, if you pass a zero-length collection as the `newElements` parameter, this method removes the elements in the given subrange without replacement. Calling the `removeSubrange(_:)` method instead is preferred. Calling this method may invalidate any existing indices for use with this collection. - Parameters: - subrange: The subrange of the collection to replace. The bounds of the range must be valid indices of the collection. - newElements: The new elements to add to the collection. - Complexity: O(*n* + *m*), where *n* is length of this collection and *m* is the length of `newElements`. If the call to this method simply appends the contents of `newElements` to the collection, this method is equivalent to `append(contentsOf:)`.

method · iOS 15.0+

index

TypeScript
indexAfter(i: FilePath_ComponentView_Index): FilePath_ComponentView_Index
Swift declaration
func index(after i: FilePath.ComponentView.Index) -> FilePath.ComponentView.Index

Returns the position immediately after the given index. The successor of an index must be well defined. For an index `i` into a collection `c`, calling `c.index(after: i)` returns the same index every time. - Parameter i: A valid index of the collection. `i` must be less than `endIndex`. - Returns: The index value immediately after `i`.

method · iOS 15.0+

index

TypeScript
indexBefore(i: FilePath_ComponentView_Index): FilePath_ComponentView_Index
Swift declaration
func index(before i: FilePath.ComponentView.Index) -> FilePath.ComponentView.Index

Returns the position immediately before the given index. - Parameter i: A valid index of the collection. `i` must be greater than `startIndex`. - Returns: The index value immediately before `i`.

get · iOS 15.0+

endIndex

TypeScript
get endIndex(): FilePath_ComponentView_Index
Swift declaration
var endIndex: FilePath.ComponentView.Index { get }

The collection's "past the end" position---that is, the position one greater than the last valid subscript argument. When you need a range that includes the last element of a collection, use the half-open range operator (`..<`) with `endIndex`. The `..<` operator creates a range that doesn't include the upper bound, so it's always safe to use with `endIndex`. For example: let numbers = [10, 20, 30, 40, 50] if let index = numbers.firstIndex(of: 30) { print(numbers[index ..< numbers.endIndex]) } // Prints "[30, 40, 50]" If the collection is empty, `endIndex` is equal to `startIndex`.

init · iOS 15.0+

init

TypeScript
static init(): FilePath_ComponentView
Swift declaration
init()

Creates a new, empty collection.

subscript · iOS 15.0+

subscript

TypeScript
subscript(position: FilePath_ComponentView_Index): FilePath_Component
Swift declaration
subscript(position: FilePath.ComponentView.Index) -> FilePath.Component { get }

Accesses the element at the specified position. The following example accesses an element of an array through its subscript to print its value: var streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"] print(streets[1]) // Prints "Bryant" You can subscript a collection with any valid index other than the collection's end index. The end index refers to the position one past the last element of a collection, so it doesn't correspond with an element. - Parameter position: The position of the element to access. `position` must be a valid index of the collection that is not equal to the `endIndex` property. - Complexity: O(1)

Skipped declarations

No declarations were skipped in this snapshot.

All System types →