What is the “?” or “!” in front of a function in swift code

In sort It’s a options of the properties and parameters in methods

that,

? = Allows nil (if you pass in method parameter arguments than it want value so it the parameter type ? than it allows null/nil object.)

AND

! = Does not allows null/nil (If you pass in method parameter arguments than it want value if parameter type ! than it does not allow null/nil object. You have to pass not nil object).

that’s it.

Leave a Comment