如何将自己的课程导入Xcode 7游乐场? [英] How to import my own class into an Xcode 7 playground?
本文介绍了如何将自己的课程导入Xcode 7游乐场?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道之前曾问过这个问题,但是我没有找到有关Xcode 7和Swift 2的答案.许多答案只是模棱两可,不正确或过时.
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?
推荐答案
在操场上转到菜单
查看/导航器/显示项目导航器
View / Navigators / Show Project Navigator
并将您的课程文件复制到Sources
文件夹中.
and copy your class files into the Sources
folder.
您的班级必须这样标记为public
:
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()
这篇关于如何将自己的课程导入Xcode 7游乐场?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文