blob: 9d9ce61899713182f57e387852a401822b783c22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
//
// NSString_AITruncation.m
// PSMTabBarControl
//
// Created by Evan Schoenberg on 7/14/07.
// From Adium, which is licensed under the GPL. Used in PSMTabBarControl with permission.
// The contents of this remain licensed under the GPL.
//
#import "NSString_AITruncation.h"
@implementation NSString (AITruncation)
+ (id)ellipsis
{
return [NSString stringWithUTF8String:"\xE2\x80\xA6"];
}
- (NSString *)stringWithEllipsisByTruncatingToLength:(NSUInteger)length
{
NSString *returnString;
if (length < [self length]) {
//Truncate and append the ellipsis
returnString = [[self substringToIndex:length - 1] stringByAppendingString:[NSString ellipsis]];
} else {
//We don't need to truncate, so don't append an ellipsis
returnString = [self copy];
}
return returnString;
}
@end
|