-4

I am having an NSString object as "HAI HELLO ABC".I want it to "HAIHELLOABC".Is there any function present?

slaveCoder
  • 519
  • 2
  • 17
  • 46
  • 4
    possible duplicate of [How to remove whitespace in a string?](http://stackoverflow.com/questions/6608420/how-to-remove-whitespace-in-a-string) – Bhumeshwer katre Dec 04 '13 at 09:09
  • 1
    You can also use stringByTrimmingCharactersInSet: see the example below. Ex: NSString *string = @"HAI ABC HELLO"; string = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; – Zac24 Dec 04 '13 at 11:36

2 Answers2

6
[str stringByReplacingOccurrencesOfString:@" " withString:@""];
rckoenes
  • 69,092
  • 8
  • 134
  • 166
Albara
  • 1,306
  • 8
  • 14
2
NSString * newString = [string stringByReplacingOccurrencesOfString:@" " withString:@""];
Maulik
  • 19,348
  • 14
  • 82
  • 137