开发者

Possible to get a constants value with string?

开发者 https://www.devze.com 2023-01-25 15:18 出处:网络
Is there a way to get a constants value by using a string for its name similar to KVC i.e: #define kStringConstTest = @\"test\";

Is there a way to get a constants value by using a string for its name similar to KVC i.e:

#define kStringConstTest = @"test";

get the value of this const by knowing that the firs开发者_JAVA技巧t part is always kStringConst and appending a dynamic second part like @"Test" to it to get its value?

thx


No, this is not possible. (I wish it were; it would make everyone's lives easier.) The alternative is to create a method that takes that dynamic string and determines the string to return using a bunch of if/else statements.

0

精彩评论

暂无评论...
验证码 换一张
取 消