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 09-09-2010, 03:23 PM   #1 (permalink)
iPhone App Developer
 
Join Date: Feb 2009
Posts: 261
GreenApple is on a distinguished road
Default Reading and Writing files to the document's folder

Hi all,

Does anyone know how do I read and write files to the App's documents folder? I have a UIView as a canvas, and I need to save the entire content in the UIView, and be able to retrieve it later. It's like all the drawing app. So it needs to use the app's documents folder, not just saving current state.

I was pointed to look at NSFileManager class, unfortunately all the sample codes are MacOS X related, not for iOS.


Anyone could give me some pointers or show me around, I'll be very much appreciated.


Many thanks.
GreenApple is offline   Reply With Quote
Old 09-10-2010, 05:06 AM   #2 (permalink)
iPhone App Developer
 
Join Date: Feb 2009
Posts: 261
GreenApple is on a distinguished road
Default

Does anyone know?
GreenApple is offline   Reply With Quote
Old 09-14-2010, 07:30 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 62
devanshree.c is on a distinguished road
Thumbs up

Quote:
Originally Posted by GreenApple View Post
Does anyone know?

NSArray *searchPaths =NSSearchPathForDirectoriesInDomains(NSDocumentDir ectory, NSUserDomainMask, YES);
NSString *documentFolderPath = [searchPaths objectAtIndex: 0];
dbFilePath = [documentFolderPath stringByAppendingPathComponent: @"Task.db"];

if (! [[NSFileManager defaultManager] fileExistsAtPath: dbFilePath]) {
//NSLog(@"didn't find db, need to copy");
NSString *backupDbPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Task.db"];
if (backupDbPath == nil) {
// couldn't find backup db to copy, bail
return NO;
} else {
BOOL copiedBackupDb = [[NSFileManager defaultManager]
copyItemAtPath:backupDbPath
toPath:dbFilePath
error:nil];
if (! copiedBackupDb) {
// copying backup db failed, bail
return NO;
}


}


this is the way i try to put my database to documents directory,....so i hope you will get some help
devanshree.c 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: 331
10 members and 321 guests
bignoggins, carlandrews, flamingliquid, hzwegjxg, ilmman, jenniead38, linkmx, nadav@webtview.com, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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