DataSource icon indicating copy to clipboard operation
DataSource copied to clipboard

Naming-Conflict with Nested Classes or Structs

Open wieweb opened this issue 6 years ago • 1 comments

class TestOne {
    struct Item {
        let value: String
    }
}

class TestTwo {
    struct Item {
        let value: Int
    }
}

dataSource.sections = [Section(items: [TestOne.Item(value: "Hello"), TestTwo.Item(value: 5)])]

This will force a crash because String(describing: type(of: item) will always return Item instead of needed TestOne.Item, TestTwo.Item. So all Items do have the same identifier and cellDescriptor will fail.

wieweb avatar May 03 '18 15:05 wieweb

String(reflecting: type(of: item)) could be used instead. It returns the full class name. Including Module though, e.g. MyApp.TestOne.Item (if you try it in Playground it'll be something like __lldb_expr_77.TestOne.Item)

SooperCode avatar Jun 22 '18 18:06 SooperCode