I recently came across the following code:
struct Bar: Identifiable {
// Type 'Bar' does not conform to protocol 'Identifiable'
}
class Foo: Identifiable {
}
For the Bar struct, Xcode complains that 'Type 'Bar' does not conform to protocol 'Identifiable' but for Foo Xcode never complains.
My understanding is that Bar is a value type and we need to supply a value for the id property to conform to the Identifiable.
Foo is reference type so its memory address is unique and thus not need to include the id conformance by Identifiable.
Is this correct?
Not exactly, there is an explicit extension for Identifiable, which makes that possible for classes:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With