sách gpt4 ăn đã đi

xcode - XCode Playgrounds 中相互引用的来源

In lại 作者:搜寻专家 更新时间:2023-11-01 07:29:01 26 4
mua khóa gpt4 giày nike

我的 Xcode Playground 的 Sources/ 目录中有代码。我可以在我的 Playground 上很好地引用它们,但我如何让它们相互引用?例如,假设我在 Sources/ 目录中有 A.swiftB.swift 文件。我想让 A.swiftB.swift 访问一些东西,但是我得到一个错误,说 B.swift 的东西是在 A.swift 中未定义。

我怎样才能做到这一点?

câu trả lời hay nhất

Sẽcông cộng 属性添加到您想要在其他playground 中访问的类、方法和属性。这应该可以解决您的问题:

You have to add public access attribute to your classes, methods and properties in source folder to make them accessible from main playground file as they treated as separate module by compiler

更新:

tôi đã tìm thấy nó this thread ,虽然我认为这不是专门针对这个主题回答了这个问题,但以下是公认的答案:

They cannot. Playgrounds are self-contained. This will hopefully change in the future.

Edit: As of Xcode 6.3, Playgrounds can now contain supporting code. They still cannot see other code in the same project, but code can be added to the support folder of a Playground that can be used from within the playground. See the Swift blog for more info.

所以,正如我之前所说,可以访问 sources 文件夹,但不能访问其他 playground。

关于xcode - XCode Playgrounds 中相互引用的来源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33880727/

26 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress