gpt4 book ai didi

ios - 如何用#define 生成字符串?

转载 作者:行者123 更新时间:2023-11-28 22:24:45 24 4
gpt4 key购买 nike

我想自动生成这样的字符串 cover.image_size(300x400)
覆盖动态 key
image_size 静态字符串
300动态号码
400动态号码

我想使用#define

#define WADImageSize(Key,Height,Width) (Key @".image_size" @"("Height @"x" Width@")")

NSLog(@" %@",WADImageSize(@"cover", @"300", @"400"));
Result will be like this **cover.image_size(300x400)**

这个工作正常,但我想为“cover”、“height”和“width”使用变量

我正在尝试这个//#define DLogW(fmt,...) (fmt ##VA_ARGS ) 但没有任何效果..

NSLog(@" %@",WADImageSize(key, height, width));

有什么帮助吗?


最佳答案

试试这个(来自 Crystal 球的代码):

#define WADImageSize(Key, Height, Width) ([NSString stringWithFormat:@"%@.image_size(%dx%d)", Key, Height, Width])

关于ios - 如何用#define 生成字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19274039/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com