Why do we need separate “.swift” files for each class?

后端 未结 6 1244
刺人心
刺人心 2020-12-29 05:02

Wondering if you might be able to answer a very basic beginner question for me. I’m working through the Cocoa + Swift tutorial on Lynda and I’m a little confused about class

6条回答
  •  抹茶落季
    2020-12-29 05:38

    As good practice:

    If the classes are unrelated, lengthy or used independently from other unrelated classes then they should be in separate files.

    However, if the classes are tightly coupled with one another and are not lengthy then they could be in the same file.

    This post also touches on this subject.

提交回复
热议问题