2012-03-19 56 views
0

我创建了一个名为PhobiaList.plist的.Plist。 林不知道我将如何实施plist,以便当按钮1被按下时,它会显示随机进入lable1?.Plist数组生成随机字符串到UILabel

+0

你的意思是从plist中随机输入吗? – Max 2012-03-19 08:46:23

+0

是的。然后显示随机条目到我的uilabel – user1277828 2012-03-19 08:57:57

+0

好的。我希望我的回答可以帮助你。否则只是问你不明白的东西。 – Max 2012-03-19 09:01:59

回答

2

假设你有一个数组存储在你的plist中。然后您可以生成0到[theArray count]之间的随机数。

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

通过调用选择的字符串。

NSString* yourRandomString = [theArray objectAtIndex:randomIndex];