领域列名称与Swift变量名称

时间:2016-08-30 14:38:42

标签: swift realm realm-migration

我正在尝试创建一个Realm数据库,其中的列包含特殊字符,并且所有数字都是' 2010'或者'分享%'。

我可以使用Realm Browser创建Realm甚至使用http://www.realmgenerator.eu/创建Realm对象但是当我将模型放在Xcode中时,Xcode会抱怨命名约定。

PrefActivity

有一些解决方法吗?我希望避免将我的专栏命名为Year2016或2017Percent或者其他很长的内容,因为我想在我的应用中显示这些数据。

1 个答案:

答案 0 :(得分:1)

您必须遵循Swift的变量命名限制。根据{{​​3}},"Constant and variable names cannot contain whitespace characters, mathematical symbols, arrows, private-use (or invalid) Unicode code points, or line- and box-drawing characters. Nor can they begin with a number, although numbers may be included elsewhere within the name."。这解释了为什么Xcode不喜欢它们中的变量名称和符号,并且没有解决方法来命名变量,如问题中所述。