Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naming-Conflict with Nested Classes or Structs #14

Open
wieweb opened this issue May 3, 2018 · 1 comment
Open

Naming-Conflict with Nested Classes or Structs #14

wieweb opened this issue May 3, 2018 · 1 comment

Comments

@wieweb
Copy link
Member

wieweb commented May 3, 2018

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.

@SooperCode
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants