Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

Is there is any tutorial to explain folder creation in iOS app?

In My application there is a home page contain different type of document. I want to arrange documents in folder with respect to the type of documents. can any one help?

share|improve this question
    
please did you read about NSFileManager read this techotopia.com/index.php/Working_with_Files_on_the_iPhone –  Nitin Gohel Aug 5 '14 at 6:27

1 Answer 1

up vote 2 down vote accepted

Use this method to create folders in your Application's Document directory folder:

- (void)createFolderWithName:(NSString *)aName {
    NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                                NSUserDomainMask,
                                                                YES) lastObject];
    NSString *folder = [documentsDirectory stringByAppendingPathComponent:aName];

    // Create the folder if necessary
    BOOL isDir = NO;
    NSFileManager *fileManager = [[NSFileManager alloc] init];
    if (![fileManager fileExistsAtPath:folder
                       isDirectory:&isDir] && isDir == NO) {
        [fileManager createDirectoryAtPath:folder
           withIntermediateDirectories:NO
                            attributes:nil
                                 error:nil];
    }
}

Update:

In order to list all folders in your document directory you need to first get list of all the files/folders and then use a UITableView to display them, when user clicks on a sub-folder then you repeat the process with updated path. For details go through this Source Code

share|improve this answer
    
asifmujteba thanks for your answer. But my need is to create and show folder in the application screen itself –  Mary Aug 5 '14 at 7:00
1  
do you want to know how to list all the folders on the screen ? –  Asif Mujteba Aug 5 '14 at 7:13
    
you are develop app and IOS not display folder on itself. what is home screen..? that create by you not by ios so you have to manage your self not folder disply it self @Mary –  Nitin Gohel Aug 5 '14 at 7:21
    
asifmujteba yes thats my need –  Mary Aug 5 '14 at 8:57
    
see my updated answer! –  Asif Mujteba Aug 5 '14 at 9:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.