Search code examples
swiftxcodexcode9unsafemutablepointer

"'deinitialize()' is deprecated: the default argument to deinitialize(count:) has been removed" warning in Xcode


I'm trying to deinitialize an UnsafeMutablePointer with this code:

pointer.deinitialize()

This has worked fine before, but Xcode 9.3 threw me a warning:

'deinitialize()' is deprecated: the default argument to deinitialize(count:) has been removed, please specify the count explicitly

How should I do this?


Solution

  • You should provide the count argument explicitly - it should be the count of the values which you want to deinitialize.

    From Apple Developer Documentation:

    deinitialize(count:)

    Deinitializes the specified number of values starting at this pointer.

    Parameters

    count

    The number of instances to deinitialize. count must not be negative.