What is optional chaining in Swift?

Optional chaining is a process for querying and calling properties, methods, and subscripts on an optional that might currently be nil . If the optional contains a value, the property, method, or subscript call succeeds; if the optional is nil , the property, method, or subscript call returns nil .

Read more

Should I use optional chaining?

You can use optional chaining when attempting to call a method which may not exist . This can be helpful, for example, when using an API in which a method might be unavailable, either due to the age of the implementation or because of a feature which isn’t available on the user’s device.

Read more