Closed binkdotli closed 8 years ago
Thanks for PR. this shadowing thing, is it because enum case collide with class in some way ?
Yes. E.g. if we have a custom class SomeTableViewCell: UITableViewCell
, which in the storyboard is identified as "SomeTableViewCell" (same identifier as class name), it will now generate:
extension SomeTableViewController {
enum Reusable: String, CustomStringConvertible, ReusableViewProtocol {
case SomeTableViewCell_ = "SomeTableViewCell"
var kind: ReusableKind? {
switch (self) {
case SomeTableViewCell_:
return ReusableKind(rawValue: "tableViewCell")
}
}
var viewType: UIView.Type? {
switch (self) {
case SomeTableViewCell_:
return SomeTableViewCell.self
}
}
Before, there would be a compile error on the last return.
Using an underscore at the end of the identifier to disambiguate does not interfere with auto-completion, and the underscore is only added in the cases where the identifiers clash. Of course the user could change the identifier in the storyboard to work around the issue, but I prefer that it works without any changes.
That's interesting case. I just don't like underscored prefix to be honest. If we'd knew the module we could use Module.SomeTableViewCell
to identify the class, but we can't.
how about if we add "ReusableCell" in place of "_" resulting SomeTableViewCellReusableCell
for enum. WDYT ?