-2

I'm loading xml data to my Xcode project in objective-c and I'm getting many "spaces" in my data.

For example - I load this value:

"lehavim"

and I'm getting it in my project like this:

"         lehavim"

Can you please help me with this one? I have checked my code many times and can't figure it out.

Suresh D
  • 4,303
  • 2
  • 29
  • 51
Amir Foghel
  • 853
  • 1
  • 12
  • 28

2 Answers2

0

As I remember I got same problem with my project when I use NSXMLParser for parsing XML. Finally, I just trim those leading spaces like in this example.

Pesky new lines and whitespace in XML reader class

Community
  • 1
  • 1
Sergnsk
  • 3,305
  • 3
  • 23
  • 28
0

Use this,

NSString *data=@"           lehavim";   
NSString *Trimmed_String=[data stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];  
NSLog(@"%@",Trimmed_String);

OUTPUT :
"lehavim"

Suresh D
  • 4,303
  • 2
  • 29
  • 51