开发者

random number sqlite iphone

开发者 https://www.devze.com 2023-02-17 21:19 出处:网络
I\'m trying to get a random number and match it up with a sqlite row.So far I have: number = (arc4random()%8)+1;

I'm trying to get a random number and match it up with a sqlite row. So far I have:

number = (arc4random()%8)+1;
NSString *string = [NSString stringWithFormat:@"%i",number];
_label.text = string;

I'm confused on how I take this random number and match it with sqlite? I'm trying to display "recipe.name". Also, how could I inc开发者_JS百科orporate "count" into this so that it limits the random number by the number of rows in the sqlite table?

Thanks in advance!


You can use the following method to do that

int randumNumber = RandomNumber() % numberOFRows;
0

精彩评论

暂无评论...
验证码 换一张
取 消