首页 > 学院 > 开发设计 > 正文

Objective-c在宏里拼接字符串

2019-11-17 03:19:58
字体:
来源:转载
供稿:网友

Objective-c在宏里拼接字符串

//正式服务器#define API_DOMAIN @"www.online.com"//测试服务器//#define DOMAINXX @"192.168.0.10"#define API_SYSTEM @"http://"API_DOMAIN@"/system/"#define API_USER @"http://"API_DOMAIN@"/user/"API_SYSTEM 宏展开后是: @"http://"@"www.online.com"@"/system/"编译器会自动将字符中连接起来,目的实现。c语言下的实现://正式服务器#define API_DOMAIN "www.online.com"//测试服务器//#define DOMAINXX "192.168.0.10"#define API_SYSTEM "http://"API_DOMAIN"/system/"

#define API_USER "http://"API_DOMAIN"/user/"

参考:http://stackoverflow.com/questions/8844981/how-to-expand-a-macro-into-nsstring-without-using-any-string-concatenation-at-ru

http://stackoverflow.com/questions/798221/c-macros-to-create-strings

最后,感谢万能的google,万能的stackoverflow。


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表