问题描述
我想在整个项目中使用一些扩展名,但是我不确定是否应该将其保留在自己的文件中,还是只在每个viewController文件中进行特定的扩展名.
I have a few extensions that I'd like to use throughout my project but I'm unsure if I should keep them in their own file, or if I should just make specific extensions in each viewController file.
哪个会更有效或更有效?
Which would be more efficient or better?
推荐答案
我认为这很大程度上是样式问题,而不是效率问题.也就是说,是的,您应该将它们放在自己的文件中.这样,如果要在项目之间重用它们,则只需将它们拖放到新项目中即可.
I think this is largely a matter of style rather than efficiency. That said, yes you should put them in their own file. That way if you want to reuse them between projects, you can simply drag and drop them into a new project.
通常,最好使文件尽可能小且模块化,以使事情简单.如果某项功能与该文件或Viewcontroller无关,那么我认为您应该将其分解为自己的文件.
In general, it is best to keep your files as small and modular as possible in order to keep things simple. If a piece of functionality doesn't specifically pertain to that file or viewcontroller then I think you should break it into its own file.
这篇关于我应该将扩展名保留在自己的“扩展名"中吗?文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!