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 05-10-2010, 06:52 PM   #1 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 1
kurbz is on a distinguished road
Question Most optimal way for me to save data?

Okay, so I've been looking everywhere trying to find out how I can save data in my app and I'm getting so confused. I've seen NSUserDefaults, SQLite, archiving, plist, and I really don't know which would be best in my case.

So basically, I want to save a list of custom objects to a file. In the app I specify some data and have it save a new custom object along with the others. Then I have a table view to show all the saved objects.

So basically I'm trying to save an NSMutableArray of custom objects.

So which method should I use?
kurbz is offline   Reply With Quote
Old 05-10-2010, 06:54 PM   #2 (permalink)
A Single-Serving Friend
 
Join Date: Mar 2010
Location: Groningen, NL
Posts: 491
Robert Paulson is on a distinguished road
Default

Hi,

I cannot really tell you which is the best way to do it. I am in a similar situation you are (from what I can tell) and I have decided to stick to this: Core Data Tutorial for iPhone OS.

Good luck.

Cheers,
Bob
__________________
We are God’s middle children, according to Tyler Durden, with no special place in history and no special attention.

Consider saying thanks by buying my app. :]
Robert Paulson is offline   Reply With Quote
Old 05-13-2010, 02:45 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 77
tazboy is on a distinguished road
Default

I am also interested in being able to save an array of custom objects. Someone was talking about turning the objects into NSData but I'm not sure how that's implemented. If anyone has any suggestions I would also appreciate it.

Thanks.
tazboy is offline   Reply With Quote
Old 05-13-2010, 04:54 PM   #4 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 77
tazboy is on a distinguished road
Default

This site helped me figure it out.

CocoaDevCentral: Saving Cocoa Application Data
tazboy is offline   Reply With Quote
Old 05-14-2010, 03:05 PM   #5 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 78
bigdiggyiPhone is on a distinguished road
Default

There are a number of ways.

Probably the easiest is to make your objects support the NSCoding Protocol. Once they do, you can call encodeWithCoder and initWithCoder methods of the NSArray that is holding the objects and they will get "packed" up into the file you specify.

Core Data is great if you have a lot of objects and relationships that would be best served by a database of some sort. Core Data abstracts the database into a more object oriented view of the world. But be forewarned, Core Data learning curve is steep. But the power you wield is awesome.

Good Luck,

t
__________________
Check out my apps:
  • Friis-It NF. Easily calculate the Noise Figure, Sensitivity, and gain of an RF receiver design.
  • RetireMax. Get a dose of reality about that next purchase!
bigdiggyiPhone is offline   Reply With Quote
Reply

Bookmarks

Tags
custom, data, file, object, save

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: 320
14 members and 306 guests
Abidullah, baja_yu, cgokey, Duncan C, Fstuff, gbenna, guusleijsten, jbro, mdpauley, n00b, newDev, Sami Gh, seokwon lee, Steven.C
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,648
Threads: 94,113
Posts: 402,877
Top Poster: BrianSlick (7,990)
Welcome to our newest member, brandon6031
Powered by vBadvanced CMPS v3.1.0

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