SharadCodes SharadCodes - 10 months ago 40
Swift Question

Swift: inherit from Class within the project

How to inherit from any other class within the project? I tried to use import. But as I have read, it is used to import other packages.
The sample code is below.

class MyClass: AnotherClass { //error: use of undeclared type 'AnotherClass'


class AnotherClass {
var name: String


In order to import a class from a different file you will need to mark your class as public in its declaration.

public class AnotherClass {
    var name: String