How to Define a class in Swift

Define a class in Swift:

The class keyword introduces a class definition and is immediately followed by the class name.


public class Test{

Class Names: Class names are identifiers that use the camel-case naming scheme. Class names begin with an initial uppercase letter.

Class Body: A left brace {, begins the body of every class definition. A corresponding right brace }, ends each class definition. By convention, the contents of a class’s body are indented.

Note: A class must be defined before you use it, otherwise you’ll receive errors indicating that you’re using an undeclared type. In an Xcode project, if you define a class in a separate [no-highlight].swift[/no-highlight] file, the IDE allows you to use it in the project’s other source code files.