开发者

How can I get a Random quote (text) from a database (CoreData) of quotes? (iPhone)

开发者 https://www.devze.com 2023-01-07 15:12 出处:网络
I want to develop an ap开发者_JAVA百科p that gives a random quote every time you change the page. And I want to put like 1000 quotes in the database. How is the best way I can get a Random Quote?arc4r

I want to develop an ap开发者_JAVA百科p that gives a random quote every time you change the page. And I want to put like 1000 quotes in the database. How is the best way I can get a Random Quote? arc4random?


To extend the answer you were given on selecting a method to generate a random number - choose a random number method, and have an index for each quote in the DB so that you can query a quote directly from the random number you compute.

Also you can get counts directly from Core Data (without doing a real query) to figure out the range of random numbers you want to ask for.

0

精彩评论

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