• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: HELP!! [self needsHelpWith:strings];
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >HELP!! [self needsHelpWith:strings]; (From: Christopher OBrien <email@hidden>)

  • Prev by Date: Re: Finding the firstResponder TextField or TextView
  • Next by Date: RE: some OS X architectural questions
  • Previous by thread: Re: HELP!! [self needsHelpWith:strings];
  • Next by thread: Java program using Cocoa Classes dying...
  • Index(es):
    • Date
    • Thread