3

In Swift, to get a null, I used UnsafeMutablePointer.null() but this did not work. Xcode says it is unavailable and I should use nil literal instead which gives me another error message. Do you have a fix?

Thanks.

1
  • 1
    Please provide some context. Where do you need the null pointer? Show your code and the exact error messages. Commented Jun 13, 2015 at 20:11

1 Answer 1

5

I stumbled upon this post while trying to answer this question myself, and I found that this worked for me

let nullPtr = UnsafeMutablePointer<Int>(nil) // nil is the null pointer 
Sign up to request clarification or add additional context in comments.

1 Comment

This answer does nothing different than var nullPtr: UnsafeMutablePointer<Int>? = nil or simply passing nil as the parameter where an UnsafeMutablePointer<Int>? is expected based on documentation.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.