Sha256: 7f2f110e4b98c7d82282637904e020622afb0aac6a70dc30eb33c5ba3c951679

Contents?: true

Size: 724 Bytes

Versions: 4

Compression:

Stored size: 724 Bytes

Contents

//
//  NSStringWhiteSpace.m
//  YueBao
//
//  Created by eiffel on 10-4-8.
//  Copyright 2010 www.likenote.com. All rights reserved.
//

#import "NSStringWhiteSpace.h"


@implementation NSString (Whitespace)

- (NSString *)stringByCompressingWhitespaceTo:(NSString *)seperator
{
	NSArray *comps = [self componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
	NSMutableArray *nonemptyComps = [[[NSMutableArray alloc] init] autorelease];
	
	// only copy non-empty entries
	for (NSString *oneComp in comps)
	{
		if (![oneComp isEqualToString:@""])
		{
			[nonemptyComps addObject:oneComp];
		}
		
	}
	
	return [nonemptyComps componentsJoinedByString:seperator];  // already marked as autoreleased
}
@end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
appjam-0.1.0.pre11 lib/appjam/generators/project/utils/NSStringWhiteSpace.m
appjam-0.1.0.pre9 lib/appjam/generators/project/utils/NSStringWhiteSpace.m
appjam-0.1.0.pre6 lib/appjam/generators/project/utils/NSStringWhiteSpace.m
appjam-0.1.0.pre4 lib/appjam/generators/utils/NSStringWhiteSpace.m