iphone - .Plist 数组生成随机字符串到 UILabel

标签 iphone ios xcode plist

我创建了一个名为 PhobiaList.plist 的 .Plist。 我不确定我将如何实现 plist,以便在按下 button1 时它会显示随机进入 lable1?

最佳答案

假设您的 plist 中存储了一个数组。然后您可以生成一个介于 0 和 [theArray count] 之间的随机数。

NSInteger randomIndex = arc4random() % [theArray count];

通过调用选择字符串。

NSString* yourRandomString = [theArray objectAtIndex:randomIndex];

关于iphone - .Plist 数组生成随机字符串到 UILabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9767142/

相关文章:

iphone - 下一页-上一页 有大量浏览量

ios - 应用程序在点击时崩溃并显示消息 : 'this class is not key value coding-compliant for the key postReplyButton.'

iphone - 如何动态更改我的应用程序中的 openURL 实现?

iphone - 创建一个类似于 iPod "Now Playing"按钮的导航按钮

ios - 如何让选中的tableview单元格像Vine App一样没有颜色

ios - CALayer 在动画之前已经出现在屏幕上

ios - Swift:将 View Controller 的类型更改为 UIViewController 以外的类型

xcode - 未找到调试 iphonesimulator/YogaKit/YogaKit.modulemap'

iphone - AVPlayer和本地文件

ios - HealthTap 是使用 phonegap cordova 开发的吗?