Reputation: 10748
I just created my first custom Swift class and I noticed that it didn't add the class name when I ceated the swift file, in fact the only thing in that file is the import statement for the foundation. If I'm not mistaken Xcode copies the file name when you create Obj-C classes.
Is it a good naming convention to name your custom classes the same as the file name in Swift/iOS?
Upvotes: 1
Views: 1184
Reputation: 93191
Yes it is a good practice. If the IDE doesn't do it, do it yourself for the sake of your sanity. I don't want to open a project with tens of classes where the class Person
is defined in file1.swift
.
Upvotes: 3
Reputation: 318884
Yes, just like in other languages, it is good practice to name the file the same as the class. It avoids confusion and makes it clear.
Upvotes: 2