ios - How to Nil a object in Swift -


how assign nil object in swift. i'm getting error if assigned directly.

enter image description here

from apple documentation:

nil cannot used nonoptional constants , variables. if constant or variable in code needs work absence of value under conditions, declare optional value of appropriate type

also importante notice:

swift’s nil not same nil in objective-c. in objective-c, nil pointer nonexistent object. in swift, nil not pointer—it absence of value of type. optionals of type can set nil, not object types

i hope helps you!

.


Comments