diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2008-09-10 02:06:39 +0000 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2010-09-30 07:08:28 +0000 |
commit | d5db7abfd39fe9a9475d73c0d792b4ae56fe2b0c (patch) | |
tree | 1f8000353912c66d07adbe205f5ecf547818eb03 /UICaboodle | |
parent | facbc56de5a9dd53b0ce257f414cf9b9beee2229 (diff) |
Adding file from backup iphone.
Diffstat (limited to 'UICaboodle')
-rw-r--r-- | UICaboodle/UCString.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/UICaboodle/UCString.h b/UICaboodle/UCString.h new file mode 100644 index 0000000..77ee6a1 --- /dev/null +++ b/UICaboodle/UCString.h @@ -0,0 +1,26 @@ +#ifndef UICABOODLE_UCSTRING_H +#define UICABOODLE_UCSTRING_H + +#import <Foundation/NSString.h> + +@interface NSString (UICaboodle) ++ (NSString *) stringWithDataSize:(double)size; +@end + +@implementation NSString (UICaboodle) + ++ (NSString *) stringWithDataSize:(double)size { + unsigned power = 0; + while (size > 1024) { + size /= 1024; + ++power; + } + + static const char *powers_[] = {"B", "KiB", "MiB", "GiB"}; + + return [NSString stringWithFormat:@"%.1f%s", size, powers_[power]]; +} + +@end + +#endif/*UICABOODLE_UCSTRING_H*/ |