-1

I am making an application which takes picture from Camera and store those pics in my Documents Folder of my application.

Now I want my application to restrict for the storage size. Like Only the 200MB of Pics can be storied in my Documents Folder.

What do i Need to achieve that feature. Do we have anything regarding that.

Thanks

Shah
  • 4,990
  • 10
  • 48
  • 70
  • Did you see that sweet little search box on the upper right corner? http://stackoverflow.com/questions/2188469/calculate-the-size-of-a-folder – Christian Schnorr Apr 03 '12 at 07:54

1 Answers1

1

What I can suggest you is ,You can get or find the size of every image you save. Now you can manage some database or can use NSUserDefaults to save the value of the size and when your total saving reaches 200MB then warn the user for exceeding the limit. This way you can manage.

And yes you can find the size of image with the properties available.

For example for a JPEG file you can do something like this

+ (NSInteger)bytesInImage:(UIImage *)image {
    CGImageRef imageRef = [image CGImage];
    return CGImageGetBytesPerRow(imageRef) * CGImageGetHeight(imageRef);    
}

Hope it helps you. Cheers

Sabby
  • 2,586
  • 2
  • 27
  • 41