Changeset 515
- Timestamp:
- 03/31/08 17:49:36 (9 months ago)
- Files:
-
- trunk/SapphireFrappliance/NSString-Extensions.h (modified) (1 diff)
- trunk/SapphireFrappliance/NSString-Extensions.m (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/SapphireFrappliance/NSString-Extensions.h
r461 r515 51 51 @end 52 52 53 @interface NSString (Additions) 54 /*! 55 * @brief Crop a string (path) into something shorter 56 * 57 * This method creates a crops a string (path) if it is greater than the desired path component length 58 * 59 * @param directoryPath The path string 60 * @param toLength The number of path components to return 61 * @return The new string after cropping 62 */ 63 + (NSString *)stringByCroppingDirectoryPath:(NSString *)directoryPath toLength:(int)requestedLength; 64 @end 65 53 66 /*! 54 67 * @brief Mutable string extensions for Replacements trunk/SapphireFrappliance/NSString-Extensions.m
r461 r515 40 40 @end 41 41 42 @implementation NSString (Additions) 43 + (NSString *)stringByCroppingDirectoryPath:(NSString *)directoryPath toLength:(int)requestedLength 44 { 45 int dirLength=[[directoryPath pathComponents] count]; 46 NSString *returnPath=directoryPath ; 47 if(dirLength>requestedLength) 48 { 49 NSLog(@"Directory %@ is %d - req %d",directoryPath, dirLength,requestedLength); 50 NSRange croppedRange; 51 croppedRange.location=dirLength-requestedLength; 52 croppedRange.length=requestedLength; 53 returnPath=[NSString stringWithFormat:@" ../%@/",[NSString pathWithComponents:[[directoryPath pathComponents] subarrayWithRange:croppedRange]]]; 54 } 55 return returnPath; 56 } 57 @end 58 59 42 60 @implementation NSMutableString (Replacements) 43 61 - (void)replaceAllOccurancesOf:(NSString *)search withString:(NSString *)replacement
