init(referencing:)
Initialize a Data by adopting a reference type.
Declaration
init(referencing reference: NSData)Parameters
- reference:
The instance of
NSDatathat you wish to wrap. This instance will be copied bystruct Data.
Discussion
You can use this initializer to create a struct Data that wraps a class NSData. struct Data will use the class NSData for all operations. Other initializers (including casting using as Data) may choose to hold a reference or not, based on a what is the most efficient representation.
If the resulting value is mutated, then Data will invoke the mutableCopy() function on the reference to copy the contents. You may customize the behavior of that function if you wish to return a specialized mutable subclass.