Quickly how to extend your own class in separate files

I want to do the following:

MyClass.swift:

public class MyClass {
    ...
}

MyClass + Extension.swift:

extension MyClass {
   ...
}

If I have both files in one file, it works fine, if they are in separate files, I get the following error:

"Use of undeclared type 'MyClass'"

I have already verified the target membership of both files. They are part of the same goal.

Any help is much appreciated!

+4
source share
1 answer

The following will allow you to access your additional functions in MyClass + Extension.swift from any place where your original MyClass is available, which was included outside its module, since it had an access level public:

public extension MyClass {
   ...
}
+1
source

All Articles