Skip to content

Instance MethodFoundationEssentials

range(of:options:in:)

iOS 8.0+ iPadOS 8.0+ Mac Catalyst 8.0+ macOS 10.10+ tvOS 9.0+ watchOS 2.0+
Find the given Data in the content of this Data.
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.