gpt4 book ai didi

ios - 如何从可用字符串中选择随机字符串

转载 作者:行者123 更新时间:2023-11-28 20:02:36 25 4
gpt4 key购买 nike

我有几个字符串。

NSString *st1 = @"png1";
NSString *st2 = @"png2";
NSString *st3 = @"png3";

我有一个SKTexture

SKTexture *Texture = [SKTexture textureWithImageNamed: @"????"];

如何从 st1st2st3 中的“????”处选择一个随机字符串。

我用 arc4random 试过了,它只对整数有效,但对字符串我无法解决我的问题。

谁能帮帮我?感谢您的回答。

最佳答案

NSArray *a = @[st1, st2, st3];
SKTexture *Texture = [SKTexture textureWithImageNamed: a[arc4random_uniform(a.count)]];

关于ios - 如何从可用字符串中选择随机字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23336087/

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