Writing objects to file?

N

Nebs Petrovic

Hey,

I'm wondering if it's possible to save a group of objects in a file so
that they are present whenever the application is run.

Example:
Let's say we have a class Car and we have a program that let's users add
a bunch of cars. When the user adds a car it is pushed into an array of
Cars. I want to be able to save this whole array along with all the
objects and their variables in tact so that next time the program is run
all the user data will be there as if they hadn't closed the program.

I can always come up with my own file formatting and save the individual
instance variables of the objects and then recreate the objects on load
but it just seems like there should be an easier way. Maybe dump the
array memory into a file and then recall it quickly on load?

Thanks.
 
F

Farrel Lifson

2008/8/6 Nebs Petrovic said:
I'm wondering if it's possible to save a group of objects in a file so
that they are present whenever the application is run.


Try PStore or Marshal or if you want something human readable and editable YAML

Farrel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top