0

I want to create a sub folder to store the images which is captured by camera & also require to store images in to the database and retrieve the images From the database.

So please provide me help regarding how to create a folder in iPhone & how to store the images in to the database & retrieve them

1 Answer 1

7

To create a directory in the documents folder,

- (void)createDirectoryInDocumentsFolderWithName:(NSString *)dirName { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *yourDirPath = [documentsDirectory stringByAppendingPathComponent:dirName]; NSFileManager *fileManager = [NSFileManager defaultManager]; BOOL isDir = YES; BOOL isDirExists = [fileManager fileExistsAtPath:yourDirPath isDirectory:&isDir]; if (!isDirExists) [fileManager createDirectoryAtPath:yourDirPath withIntermediateDirectories:YES attributes:nil error:nil]; } 
Sign up to request clarification or add additional context in comments.

3 Comments

@jaydev you ought to accept the answers that have helped you. To do that click on the checkbox next to the answer
@EmptyStack Can you guide me how to retrieve data from these particular folders created.
Try this answer. stackoverflow.com/questions/6546563/…. In that change the line NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"txtFile.txt"]; to NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"yourDir/txtFile.txt"];

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.