Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-17-2010, 02:25 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 39
Lucasdms is on a distinguished road
Question Random text from Core Data

I'm developing an app that shows a Random Quote when you press a button, and anyone knows if is possible to put all my quotes in a CoreData, and when the User press the button, it'll give another quote. How can I do this?


Thanks,
Lucas
Lucasdms is offline   Reply With Quote
Old 07-17-2010, 03:49 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Boston, MA
Posts: 135
carbonbasednerd is on a distinguished road
Default

Quote:
Originally Posted by Lucasdms View Post
I'm developing an app that shows a Random Quote when you press a button, and anyone knows if is possible to put all my quotes in a CoreData, and when the User press the button, it'll give another quote. How can I do this?


Thanks,
Lucas
when the app loads you could do a check to see if the data is there and if it's not, then load it into core data. One way to do this would be to create a json file that has all the quotes you want on it and read from that file for your initial load. This way, if you ever want to add any you just need to update that file rather then hardcoding it in place.
carbonbasednerd is offline   Reply With Quote
Old 07-17-2010, 07:03 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 39
Lucasdms is on a distinguished road
Question

But don't you think the "loading page" would be very slow. Like: The first version of the app has 1000 quotes.

Thanks for ur reply.
Lucasdms is offline   Reply With Quote
Old 07-17-2010, 07:10 PM   #4 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Boston, MA
Posts: 135
carbonbasednerd is on a distinguished road
Default

If you have a lot to load, maybe. But only on the very first time the app is run. I'm not sure if 1000 would be a problem though. I have never load tested core data. Should be easy enough to find out though by experimenting.

If you do it this way it probably would make sense to create all your objects and save them at the same time. Don't forget to clean 'em up when you are done too.
carbonbasednerd is offline   Reply With Quote
Old 07-17-2010, 07:22 PM   #5 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 39
Lucasdms is on a distinguished road
Question

How do you think it's the best way to get a random quote in a Core Data?
Lucasdms is offline   Reply With Quote
Old 07-17-2010, 07:28 PM   #6 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Boston, MA
Posts: 135
carbonbasednerd is on a distinguished road
Default

how do i think it's the best way? It's the only way I know. Best? If someone puts up another solution then I could compare them I guess. But I think it's the only way to add initial data.
carbonbasednerd is offline   Reply With Quote
Old 07-17-2010, 07:31 PM   #7 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 39
Lucasdms is on a distinguished road
Thumbs up

Okay. Thanks for you replys. Going to try do this.
Lucasdms is offline   Reply With Quote
Old 07-18-2010, 09:42 AM   #8 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 39
Lucasdms is on a distinguished road
Question

And how do you think I can get a random quote from the Json File?
Lucasdms is offline   Reply With Quote
Old 08-10-2010, 10:42 PM   #9 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 21
sbonkosk is on a distinguished road
Default

Quote:
Originally Posted by Lucasdms View Post
And how do you think I can get a random quote from the Json File?
Store the quotes using core data, when you want to display a random quote then fetch all the quotes from core data and they will be stored in an array. Get a random number from 0 to the array count and then access the quote at that array index.
sbonkosk is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 329
14 members and 315 guests
akphyo, alexP, appservice, bignoggins, EXOPTENDAELAX, flamingliquid, guusleijsten, Hamad, mariano_donati, ohmniac, Paul Slocum, Rudy, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:41 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0