diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-06-23 22:21:23 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-06-23 22:21:23 +0000 |
commit | 24f0afbfe3416b7896d0a3b4f654f04944adf39d (patch) | |
tree | 8baf8e6d89d5b57df23b5e88080e8747afaa368b /Source/SPDataAdditions.m | |
parent | ed2d754e46bd6a104f1b093b979720727e95dcb5 (diff) | |
download | sequelpro-24f0afbfe3416b7896d0a3b4f654f04944adf39d.tar.gz sequelpro-24f0afbfe3416b7896d0a3b4f654f04944adf39d.tar.bz2 sequelpro-24f0afbfe3416b7896d0a3b4f654f04944adf39d.zip |
• added to SPDataAdditions:
- (NSString *) shortStringRepresentationUsingEncoding:
--mainly used for displaying large blob data in a tableView
• tiny speed improvements for tableView:objectValueForTableColumn and tableView:setObjectValueForTableColumn in Content Browser and Custom Query
Diffstat (limited to 'Source/SPDataAdditions.m')
-rw-r--r-- | Source/SPDataAdditions.m | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Source/SPDataAdditions.m b/Source/SPDataAdditions.m index ec91f55c..8018de8a 100644 --- a/Source/SPDataAdditions.m +++ b/Source/SPDataAdditions.m @@ -187,5 +187,27 @@ static char base64encodingTable[64] = { return retVal; } +/* + * Convert data objects to their string representation (max 255 chars) + * in the current encoding, falling back to ascii. (Mainly used for displaying + * large blob data in a tableView) + */ +- (NSString *) shortStringRepresentationUsingEncoding:(NSStringEncoding)encoding +{ + NSString *tmp = [[NSString alloc] initWithData:self encoding:encoding]; + NSString *shortString; + if (tmp == nil) + tmp = [[NSString alloc] initWithData:self encoding:NSASCIIStringEncoding]; + if (tmp == nil) + return @"- cannot be displayed -"; + else { + if([tmp length]>255) + shortString = [[NSString stringWithString:tmp] substringToIndex:255]; + else + shortString = [NSString stringWithString:tmp]; + } + [tmp release]; + return shortString; +} @end |