Sha256: d931c7414cf8e0d2ef6d960230c3c4149e934d779f4dbfb15f82343a930cd417

Contents?: true

Size: 724 Bytes

Versions: 9

Compression:

Stored size: 724 Bytes

Contents

#import "NSString+Trim.h"

@implementation NSString (Trim)

- (NSString *)stringByTrimmingStartWithCharactersInSet:(NSCharacterSet *)theCharacterSet
{
    NSUInteger i = 0;
    NSUInteger length = [self length];
    while (i < length && [theCharacterSet characterIsMember: [self characterAtIndex: i]])
    {
        i++;
    }
    
    return i ? [self substringFromIndex: i] : self;
}

- (NSString *)stringByTrimmingEndWithCharactersInSet:(NSCharacterSet *)theCharacterSet
{
    NSInteger length = [self length] - 1;
    while (length > 0 && [theCharacterSet characterIsMember: [self characterAtIndex: length]])
    {
        length--;
    }
    
    return length > 0 ? [self substringToIndex: length + 1] : self;
}

@end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
xcfit-2.0.6 XCFit/Classes/Cucumberish/Dependencies/Gherkin/NSString+Trim.m
xcfit-0.9.0 XCFitDemo/XCFitDemoCucumberishTests/Cucumberish/Dependencies/Gherkin/NSString+Trim.m
xcfit-0.8.0 XCFitDemo/XCFitDemoCucumberishTests/Cucumberish/Dependencies/Gherkin/NSString+Trim.m
xcfit-0.7.0 XCFitDemo/XCFitDemoCucumberishTests/Cucumberish/Dependencies/Gherkin/NSString+Trim.m
xcfit-0.6.0 XCFitDemo/XCFitDemoCucumberishTests/Cucumberish/Dependencies/Gherkin/NSString+Trim.m
xcfit-0.5.0 XCFitDemo/XCFitDemoCucumberishTests/Cucumberish/Dependencies/Gherkin/NSString+Trim.m
xcfit-0.4.0 XCFitDemo/XCFitDemoCucumberishTests/Cucumberish/Dependencies/Gherkin/NSString+Trim.m
xcfit-0.3.0 XCFitDemo/XCFitDemoCucumberishTests/Cucumberish/Dependencies/Gherkin/NSString+Trim.m
xcfit-0.2.0 XCFitDemo/XCFitDemoCucumberishTests/Cucumberish/Dependencies/Gherkin/NSString+Trim.m