What's the best practice for naming Swift files that add extensions to existing objects?

后端 未结 7 665
面向向阳花
面向向阳花 2021-01-29 20:43

It\'s possible to add extensions to existing Swift object types using extensions, as described in the language specification.

As a result, it\'s possible to create exten

相关标签:
7条回答
  • 2021-01-29 21:42

    Why is this even a debate? Should I put all my sub classes into a file called _Subclasses.swift. I think not. Swift has module based name spacing. To extend a well known Swift class needs a file that is specific to its purpose. I could have a large team that creates a file that is UIViewExtensions.swift that express no purpose and will confuse developers and could be easily duplicated in the project which would not build. The Objective-C naming convention works fine and until Swift has real name spacing, it is the best way to go.

    0 讨论(0)
提交回复
热议问题