Instance Method

subdata(with:)

Returns a data object containing the receiver’s bytes that fall within the limits specified by a given range.

Declaration

func subdata(with range: NSRange) -> Data

Parameters

range

The range in the receiver from which to get the data. The range must not exceed the bounds of the receiver.

Return Value

A data object containing the receiver’s bytes that fall within the limits specified by range. If range isn’t within the receiver’s range of bytes, raises NSRangeException.

Discussion

A sample using this method can be found in Working With Binary Data.