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 12-09-2011, 11:43 AM   #1 (permalink)
jcc
Registered Member
 
Join Date: Aug 2010
Posts: 53
jcc is on a distinguished road
Default Data Persistence

Hi forum,

I am currently creating an app for iPad that allows users to add photos onto a canvas from their photo library. The user could potentially have 10, 20, 30, or more photos saved into the app.

Once added, these images are able to be manipulated (rotated, resized, etc.)...all of this information needs to be saved so it can be reloaded in the same state.

My current method of saving the information for each image is:
Code:
[defaults setObject:[NSKeyedArchiver archivedDataWithRootObject:imageView] forKey:@"TouchImageView"];

My questions are:

- What is the best way to manage data persistence in this particular situation?

- Is my current method for saving appropriate?...especially for such a potentially large amount of data?

Thanks!
jcc is offline   Reply With Quote
Old 12-09-2011, 01:34 PM   #2 (permalink)
Registered Member
 
ebender001's Avatar
 
Join Date: Mar 2010
Location: Missouri
Age: 57
Posts: 70
ebender001 is on a distinguished road
Default

Quote:
Originally Posted by jcc View Post
Hi forum,

I am currently creating an app for iPad that allows users to add photos onto a canvas from their photo library. The user could potentially have 10, 20, 30, or more photos saved into the app.

Once added, these images are able to be manipulated (rotated, resized, etc.)...all of this information needs to be saved so it can be reloaded in the same state.

My current method of saving the information for each image is:
Code:
[defaults setObject:[NSKeyedArchiver archivedDataWithRootObject:imageView] forKey:@"TouchImageView"];
My questions are:

- What is the best way to manage data persistence in this particular situation?

- Is my current method for saving appropriate?...especially for such a potentially large amount of data?

Thanks!
If your "defaults" variable is referring to NSUserDefaults, then you should not store images or any other large files for that matter there. If I were storing many images and wanted to access them, I would store the images in the documents directory of the app and use CoreData as a means to access the filenames of those images. Then you could add data points that might be helpful for each image (edited, rotated, etc).

Ed
ebender001 is offline   Reply With Quote
Old 12-09-2011, 01:42 PM   #3 (permalink)
jcc
Registered Member
 
Join Date: Aug 2010
Posts: 53
jcc is on a distinguished road
Default

Quote:
Originally Posted by ebender001 View Post
If your "defaults" variable is referring to NSUserDefaults, then you should not store images or any other large files for that matter there. If I were storing many images and wanted to access them, I would store the images in the documents directory of the app and use CoreData as a means to access the filenames of those images. Then you could add data points that might be helpful for each image (edited, rotated, etc).

Ed
Thanks for the reply.

Yes, I forgot to mention that the "defaults" variable was referencing NSUserDefaults.

I will try your suggestion. Thanks!
jcc is offline   Reply With Quote
Old 12-09-2011, 01:56 PM   #4 (permalink)
jcc
Registered Member
 
Join Date: Aug 2010
Posts: 53
jcc is on a distinguished road
Default

Quote:
Originally Posted by ebender001 View Post
If your "defaults" variable is referring to NSUserDefaults, then you should not store images or any other large files for that matter there. If I were storing many images and wanted to access them, I would store the images in the documents directory of the app and use CoreData as a means to access the filenames of those images. Then you could add data points that might be helpful for each image (edited, rotated, etc).

Ed
I have one more question that came to mind:

You recommended that I should save the images in the documents directory as opposed to saving the data through "archivedDataWithRootObject".

Can you elaborate as to why it is more memory efficient to actually save the file into the documents directory as opposed to saving it through "archivedDataWithRootObject"?

Thanks
jcc is offline   Reply With Quote
Old 12-09-2011, 10:56 PM   #5 (permalink)
Registered Member
 
ebender001's Avatar
 
Join Date: Mar 2010
Location: Missouri
Age: 57
Posts: 70
ebender001 is on a distinguished road
Default

Quote:
Originally Posted by jcc View Post
I have one more question that came to mind:

You recommended that I should save the images in the documents directory as opposed to saving the data through "archivedDataWithRootObject".

Can you elaborate as to why it is more memory efficient to actually save the file into the documents directory as opposed to saving it through "archivedDataWithRootObject"?

Thanks
Sorry, I was not, and can not without testing the case directly, saying to save the image or the NSData representation of the image. I was only saying it was not appropriate to save the image or data using NSUserDefault.
Ed
ebender001 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: 413
13 members and 400 guests
7twenty7, AppsBlogger, David-T, Duncan C, EvilElf, HemiMG, heshiming, iekei, LunarMoon, Murphy, sacha1996, Sami Gh, teebee74
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,915
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

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