SharadCodes SharadCodes - 1 year ago 69
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

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download