-4

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

slaveCoder
  • 539
  • 1
  • 15
  • 37
  • 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
  • 68,719
  • 8
  • 132
  • 164
Albara
  • 1,316
  • 8
  • 14
2
NSString * newString = [string stringByReplacingOccurrencesOfString:@" " withString:@""];
Maulik
  • 19,268
  • 14
  • 81
  • 136