Objective C宏附加到字符串 [英] Objective C Macro append to string
本文介绍了Objective C宏附加到字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我认为这是一件非常简单的事情,但由于我是iOS开发和目标C的新手,我无法理解。
I think this is a very simple thing to do, but since I'm new to iOS development and objective C, I can't figure it out.
#define RESTFUL_PATH_PREFIX @"https://gogch.com/gch-restful";
#define LOGIN RESTFUL_PATH_PREFIX @"/login;
我想要结果https://gogch.com/gch-restful/login
但我得到的结果为https://gogch.com/gch-restful
stackoverflow中的其他主题仅提及添加新字符串字符串的开头,例如,
other topics in stackoverflow mention only about adding a new string to the beginning of a string like,
#define DOMAIN "example.com"
#define SUBDOMAIN "test." DOMAIN
推荐答案
删除尾部分号:
#define RESTFUL_PATH_PREFIX @"https://gogch.com/gch-restful";
^
然后字符串常量可以由编译器连接:
and then string constants can be concatenated by the compiler:
@"first" @"second"
而不是:
@"first"; @"second"
这篇关于Objective C宏附加到字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文