Skip to content

Commit 9dbc366

Browse files
author
Frederick Kellison-Linn
committed
Update documentation
1 parent 1b3bc23 commit 9dbc366

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Foundation/NSData.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,21 @@ open class NSMutableData : NSData {
945945

946946
}
947947

948+
/// Replaces with a given set of bytes a given range within the contents of the receiver.
949+
///
950+
/// If the length of range is not equal to replacementLength, the receiver is resized to
951+
/// accommodate the new bytes. Any bytes past range in the receiver are shifted to accommodate
952+
/// the new bytes. You can therefore pass NULL for replacementBytes and 0 for replacementLength
953+
/// to delete bytes in the receiver in the range range. You can also replace a range (which
954+
/// might be zero-length) with more bytes than the length of the range, which has the effect of
955+
/// insertion (or “replace some and insert more”).
956+
///
957+
/// - Parameter range: range within the receiver's contents to replace with bytes. The range must not exceed the bounds of the receiver.
958+
/// - Parameter replacementBytes: data to insert into the receiver's contents.
959+
/// - Parameter replacementLength: number of bytes to take from `replacementBytes`.
960+
///
961+
/// - Note: `replacementLength` must be less than or equal to the
962+
/// size of the buffer pointed to by `replacementBytes`.
948963
open func replaceBytes(in range: NSRange, withBytes replacementBytes: UnsafeRawPointer?, length replacementLength: Int) {
949964
let bytePtr = replacementBytes?.bindMemory(to: UInt8.self, capacity: replacementLength)
950965
CFDataReplaceBytes(_cfMutableObject, CFRangeMake(range.location, range.length), bytePtr, replacementLength)

0 commit comments

Comments
 (0)