]> git.saurik.com Git - cydia.git/blame - UICaboodle/UCString.h
Use drawAtPoint:forWidth:withFont:lineBreakMode: instead of drawAtPoint:forWidth...
[cydia.git] / UICaboodle / UCString.h
CommitLineData
d5db7abf
JF
1#ifndef UICABOODLE_UCSTRING_H
2#define UICABOODLE_UCSTRING_H
3
4#import <Foundation/NSString.h>
5
11cd0308
JF
6@interface NSString (UIKit)
7- (NSString *) stringByAddingPercentEscapes;
8- (NSString *) stringByReplacingCharacter:(unsigned short)arg0 withCharacter:(unsigned short)arg1;
9@end
10
d5db7abf
JF
11@interface NSString (UICaboodle)
12+ (NSString *) stringWithDataSize:(double)size;
11cd0308 13- (NSString *) stringByAddingPercentEscapesIncludingReserved;
d5db7abf
JF
14@end
15
16@implementation NSString (UICaboodle)
17
18+ (NSString *) stringWithDataSize:(double)size {
19 unsigned power = 0;
20 while (size > 1024) {
21 size /= 1024;
22 ++power;
23 }
24
25 static const char *powers_[] = {"B", "KiB", "MiB", "GiB"};
26
27 return [NSString stringWithFormat:@"%.1f%s", size, powers_[power]];
28}
29
11cd0308
JF
30- (NSString *) stringByAddingPercentEscapesIncludingReserved {
31 return [(id)CFURLCreateStringByAddingPercentEscapes(
32 kCFAllocatorDefault,
33 (CFStringRef) self,
34 NULL,
35 CFSTR(";/?:@&=+$,"),
36 kCFStringEncodingUTF8
37 ) autorelease];
38}
39
d5db7abf
JF
40@end
41
42#endif/*UICABOODLE_UCSTRING_H*/