I know this question was asked before, but I didn't find an answer in relation to Xcode 7 and Swift 2. Many answers are just ambiguous, incorrect or outdated.
Is there a clear way to import a single class or a set of classes to a playground?
I know this question was asked before, but I didn't find an answer in relation to Xcode 7 and Swift 2. Many answers are just ambiguous, incorrect or outdated.
Is there a clear way to import a single class or a set of classes to a playground?
In the Playground go to menu
View / Navigators / Show Project Navigator
and copy your class files into the Sources
folder.
Your classes have to be marked public
like this:
public class MyPlayGround {
public class func sayHello() {
print("Hello")
}
}
The Playground will then have access to the classes:
MyPlayGround.sayHello()