[英]How to define custom localize constant in swift
I am new to swift 2 . 我是新手2。 I know define macro in objective c as
我知道在目标c中定义宏为
#define MYAPPCLocalize(Key) NSLocalizedStringFromTable(Key, APP_DELEGATE.currentStrings, @"N/A")
But how can i declare like the same in swift . 但是我怎么能迅速宣布相同。 Please help me
请帮我
I had same problem. 我有同样的问题。
Actually in swift there no concept of Macros. 实际上,没有快速宏的概念。 If you want to create simple macro then you can create it with
let
keyword which treated as a macro or something like static variable(attribute). 如果要创建简单的宏,则可以使用被视为宏或诸如static variable(attribute)之类的
let
关键字来创建它。
If you want to create parameterised macro, then create func
with parameters and return type. 如果要创建参数化的宏,请使用参数和返回类型创建
func
。
Follow solution provided in this link 遵循此链接中提供的解决方案
Create parameterised string or macro in swift? 快速创建参数化的字符串或宏?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.