gpt4 book ai didi

ios - 如何用值初始化 nsstring?

转载 作者:行者123 更新时间:2023-11-29 01:43:21 27 4
gpt4 key购买 nike

目前我正在加载我的声音

NSString * strName = [NSString stringWithFormat:@"soundpack%ld", (long) (value+1)];

获取每个声音的值。

现在我想把它从数组中拉出来。看起来像这样:

NSMutableArray * sounds = [NSMutableArray arrayWithObjects: @"soundpack1", @"soundpack2", @"soundpack3", @"soundpack4", @"soundpack5", @"soundpack6", @"soundpack7", @"soundpack8", @"soundpack9", nil];
NSUInteger count = [sounds count];

for (NSUInteger i = 0; i < count; ++i) {
NSInteger nElements = count - i;
NSInteger n = arc4random_uniform((u_int32_t )nElements) + i;
[sounds exchangeObjectAtIndex:i withObjectAtIndex:n];
}
NSString * strName0 = [sounds objectAtIndex:1];

好的,现在我已经打乱了声音。现在我想像以前一样使用特定值进行初始化。

类似于:

NSString * strName = [sounds objectAtIndex:%ld, (long) (value+1)];

NSString * strName = [sounds objectAtIndex:@"%ld", (long) (value+1)];

没用。但我不知道,现在该怎么做...

最佳答案

尝试改变这一行

NSString * strName = [sounds objectAtIndex:@"%ld", (long) (value+1)];

NSString * strName = [sounds objectAtIndex:(long) (value+1)];

关于ios - 如何用值初始化 nsstring?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32178249/

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