Contents

replaceBytes(in:withBytes:)

Replaces with a given set of bytes a given range within the contents of the receiver.

Declaration

func replaceBytes(in range: NSRange, withBytes bytes: UnsafeRawPointer)

Parameters

  • range:

    The range within the receiver’s contents to replace with bytes. The range must not exceed the bounds of the receiver.

  • bytes:

    The data to insert into the receiver’s contents.

Discussion

If the location of range isn’t within the receiver’s range of bytes, an NSRangeException is raised. The receiver is resized to accommodate the new bytes, if necessary.

A sample using this method is given in Working With Mutable Binary Data.

See Also

Modifying Bytes