访问由Folder引用添加的Swift变量 [英] Accessing Swift variables added by Folder reference

查看:123
本文介绍了访问由Folder引用添加的Swift变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我花了大约3个小时来处理这个简单的问题并且用Google搜索了很多但是没办法。
我的问题非常简单。我想将一个目录作为文件夹参考添加到我的Swift xCode项目中。但无法访问它们。

Actually I spend around 3 hours in this simple problem and googled it a lot but no way. My question is very simple. I want to add a directory as a "Folder Reference" to my Swift xCode project. But no way to access them.

我不需要使用Group Reference添加任何建议吗?

I don't need to add then using Group Reference, any suggestions?

推荐答案

更新:如果您使用的是文件夹引用,没有办法导入它们,你必须使用完整的目录路径引用它们。

Update: if you are using folder references, there is no way to import them and you must reference them using the full directory path.

EX:

let image = UIImage(named: "Images/Icons/GoPago")

这是唯一的方法。根据您的项目需要,我建议使用如下的分组。

That is the only way. Depending on what your project requires, I would suggest using groupings like below.

问题是您使用的是文件夹而不是分组。无需导入。您只需要取出文件夹中的所有内容并通过xCode分组它。然后,您就可以在代码中访问它。当您将其分组时,它应该看起来像一个黄色文件夹。像这样:

The problem is that you are using folders and not grouping. There is no import needed. You just need to take everything in the folder and "group" it through xCode. Then you will be able to access it in your code. It should look as a yellow folder when you group it in there. Like so:

它应该看起来像这个:

如果您要复制一个目录,您需要确保选择创建组,如下所示。 :

if you are copying over a directory, you would want to make sure to select create groups as follows. :

这篇关于访问由Folder引用添加的Swift变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆