Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sanjeev

macrumors newbie
Original poster
Dec 18, 2009
11
0
Hello Friends,

I have an issue.

In my app., I want to cache the images coming from server into local document directory. For that I need to create sub-folders each containing particular set of images.

I have created one sub-folder directly inside the document directory like:

/documents/subfolder1

Now, when I try to create another subfolder, it gets overwriting the first folder :( . I have been stucked here for last 2 days and I really want to complete it anyhow by the end of the day.

If anyone has any idea about this, please help me.

Prompt response will be highly appreciated.

Thanks,
 
Thanks Man,

I have implemented that succesfully.

Code:
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *string1= [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Titles"];

   NSString *string2= [[paths objectAtIndex:0] stringByAppendingPathComponent:@"EachBook"];

/* check for existence of cache directory */
	if ([[NSFileManager defaultManager] fileExistsAtPath:string1 ]) 
	{
		return;
	}
	
	/* create a new cache directory */
	if (![[NSFileManager defaultManager] createDirectoryAtPath:string1					   withIntermediateDirectories:YES attributes:nil error:&error]) 
	{
		URLCacheAlertWithError(error);
		return;
	}

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

Cheers,
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.