Re: HELP!! [self needsHelpWith:strings];
Re: HELP!! [self needsHelpWith:strings];
- Subject: Re: HELP!! [self needsHelpWith:strings];
- From: Darren Manning <email@hidden>
- Date: Tue, 21 May 2002 12:34:02 -0500
// Here's a method involving an array of characters to remove
- (NSString *)removeArrayOfChars:(NSArray *)charArray
fromString:(NSString *)inString
{
NSMutableString *newString = [[[NSMutableString alloc]
initWithString:inString] autorelease];
int i;
int j;
for (i=[newString length]-1;i>=0;i--)
for (j=0;j<[charArray count];j++)
if ([newString characterAtIndex:i] == [[charArray
objectAtIndex:j] characterAtIndex:0])
[newString deleteCharactersInRange:NSMakeRange(i, 1)];
return newString;
}
// Example of calling the method:
NSString *originalString = @"Remove spaces and < and >.";
NSString *newString;
NSArray *unwantedChars = [NSArray arrayWithObjects:@" ", @"<", @">",
nil];
newString = [self removeArrayOfChars:unwantedChars
fromString:originalString];
On Tuesday, May 21, 2002, at 10:14 AM, Christopher OBrien wrote:
Hi all. I am working on a major major project and I need to remove
certain characters from an NSString. Is it also possible to remove
white space from an NSString? All feedback is welcome and
appreciated. Thanks.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.