You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Playground页面文件中使用编译器指令并设置teacherMode?

解决Playground中设置teacherMode编译宏的问题

你的代码里的teacherMode是自定义编译条件宏,默认未被启用,所以每次运行都走学生模式分支。要切换到教师模式,需要在Playground的设置里添加编译标记,步骤如下:

  • 打开你的Playground,点击右上角的文件检查器(带横线的文档图标)。
  • 在页面右侧的Playground Settings区域,找到Custom Flags板块。
  • 在Other Swift Flags输入框中,输入 -D teacherMode(注意-D和teacherMode之间有空格)。
  • 回到代码区重新运行,此时代码就会触发#if teacherMode分支,生成教师模式的clientCode实例。

如果要切回学生模式,只需要把Other Swift Flags里的-D teacherMode删除即可。

内容的提问来源于stack exchange,提问作者jiexishede

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 05:00:31