Help with code: Swift to Objective-C

Hi,

Can anyone help translate this code to Objective-C?

Thanks



_let date = ClassName.shared.expirationDateFor("string") ?? Date()
  • * ClassName is a Singleton

Replies

Is your question about converting ?? ?

If so (https ://en.wikipedia. org/wiki/Nullcoalescingoperator)
In Obj-C, the nil coalescing operator is ?:. It can be used to provide a default for nil references:
Code Block
id value = ClassName.shared.expirationDateFor("string") ?: Date();

This is the same as writing
Code Block
id value = ClassName.shared.expirationDateFor("string") ? ClassName.shared.expirationDateFor("string") : Date();