gpt4 book ai didi

iphone - 以多个 NSString 作为参数的 Objective C 方法

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

我需要使用多个 NSString 作为参数创建 init 方法。

假设它看起来像:'-(id) initWithSomething: (NSString *) things, nil;'

如何识别字符串的个数并将它们写入数组?

问候

最佳答案

使用可变方法:

//Interface
-(id) initWithSomething:(NSString*) arg1, ...;
//Implementation
-(id) initWithSomething:(NSString*) arg1, ... {
va_list args;
va_start(args, firstObject);
id obj;
for (obj = firstObject; obj != nil; obj = va_arg(args, id))
//Do stuff with each object.
va_end(args);
}

关于iphone - 以多个 NSString 作为参数的 Objective C 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8087987/

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