From 7fb3cc0fc3898a1f1c562924fe8a8f75b5a75132 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 10 Sep 2008 02:06:39 +0000 Subject: [PATCH] Adding file from backup iphone. --- UICaboodle/UCString.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 UICaboodle/UCString.h diff --git a/UICaboodle/UCString.h b/UICaboodle/UCString.h new file mode 100644 index 00000000..77ee6a1b --- /dev/null +++ b/UICaboodle/UCString.h @@ -0,0 +1,26 @@ +#ifndef UICABOODLE_UCSTRING_H +#define UICABOODLE_UCSTRING_H + +#import + +@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*/ -- 2.47.2