Krunal
Krunal

Reputation: 1328

Issue in showing already created folder

I have been successful in creating folder in "Documents" folder in iPhone simulator.

NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"/MyFolder"];
NSLog(@"path is:%@",dataPath);

if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
{
    [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error];
}

I can see folder is created in simulator... Now I require to show that folder in my app screen. Means user can see( by clicking on '+' or anything else) that folder is created.

I have also referred iPhone/iPad: Unable to copy folder from NSBundle to NSDocumentDirectory but not as I require.....

Is is possible to show folder, created?? If yes, then how?? Any help would be appreciated....

Thanx in advance :) :)

Upvotes: 0

Views: 147

Answers (3)

iTrained
iTrained

Reputation: 31

You can check that either current item is folder or not by....

- (BOOL)createDirectoryAtURL:(NSString *)path withIntermediateDirectories:(BOOL)createIntermediates attributes:(NSDictionary *)attributes error:(NSError **)error

Upvotes: 1

jmstone617
jmstone617

Reputation: 5707

You can't show the folder in the nib. A folder is not an object you can pull out from the object library. If you want an actual folder, you could use a UIImageView with an image of a folder. Also, if you are creating directories inside of the Documents folder, I would suggest using NSFileManager's methods for creating directories:

- (BOOL)createDirectoryAtPath:(NSString *)path withIntermediateDirectories:(BOOL)createIntermediates attributes:(NSDictionary *)attributes error:(NSError **)error

or

- (BOOL)createDirectoryAtURL:(NSString *)path withIntermediateDirectories:(BOOL)createIntermediates attributes:(NSDictionary *)attributes error:(NSError **)error

Upvotes: 0

TheEye
TheEye

Reputation: 9346

Have a look here, that's how you read in all existing directories:

Get array of directories in documents directory

You can then easily show them in a table in your view.

Upvotes: 0

Related Questions