Instance Method

range(of:options:in:)

Finds the range of the specified data as a subsequence of this data, if it exists.

Declaration

func range(of dataToFind: Data, options: Data.SearchOptions = [], in range: Range<Data.Index>? = nil) -> Range<Data.Index>?

Parameters

dataToFind

The data to be searched for.

options

Options for the search. Default value is [].

range

The range of this data in which to perform the search. Default value is nil, which means the entire content of this data.

Return Value

A Range specifying the location of the found data, or nil if a match could not be found.

Discussion

Precondition: range must be in the bounds of the Data.

See Also

Finding Bytes

func first(where: (UInt8) -> Bool) -> UInt8?

Returns the first element of the sequence that satisfies the given predicate.

func max() -> UInt8?

Returns the maximum element in the sequence.

func max(by: (UInt8, UInt8) -> Bool) -> UInt8?

Returns the maximum element in the sequence, using the given predicate as the comparison between elements.

func min() -> UInt8?

Returns the minimum element in the sequence.

func min(by: (UInt8, UInt8) -> Bool) -> UInt8?

Returns the minimum element in the sequence, using the given predicate as the comparison between elements.

typealias Data.SearchOptions

Options that control a data search operation.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software