I have a UIVIew subclass in my playground sources folder (its a Public class) and I'm trying to only put a portion of this class into my main playground file as an extension.
When I declare the following in my playground
public extension SortingAlgorithmView {
public func typeTest() {
print("dfasfndjasfasfdasfdasf test ")
}
}
and then inside my subclass I call typeTest() it tells me there is no function with the name typeTest.
The interactive pages do not run alongside the source files; the source files are compiled first and then imported into your playground pages (which is why you need to make everything public
). This makes them much faster since they can be compiled just once instead of interpreted every time, but it also means they cannot reference the code in the playground pages.
If you want to access the extension from the source files, you'll have to put it in a source file. The source files cannot access the interactive content.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With