Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

to trim spaces an \n from NSString

I have NSString @" (\n "Bi_ss" \n) " I want to get String @"Bi_ss "

Any one has any idea about this ? Thank you

like image 690
anjum Avatar asked Feb 24 '12 12:02

anjum


2 Answers

NSString *trimmedString = [string stringByTrimmingCharactersInSet:
                                  [NSCharacterSet whitespaceAndNewlineCharacterSet]];

From Cocoanetics...

like image 198
Rok Jarc Avatar answered Nov 07 '22 17:11

Rok Jarc


Take a look at the NSString method stringByReplacingOccurrencesOfString:withString for example, this should be able to perform the basic task you want it to do.

like image 42
Jake Avatar answered Nov 07 '22 17:11

Jake