0

In my program, I need the users to answer the questions. However, if the users typed several spaces after typing the string, how can I eliminate all the spaces after the string in order to compare the answer correctly? I just know the method to trim one space after the string only. Thank you for the help.

Peter Lam
  • 37
  • 2
  • 8

1 Answers1

0

Read the manual.

Write the code.

NSString* trimmed = [mystring stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
  • I have used the method mentioned before. However, if i typed the space key for more than one times, than the answer became incorrect. – Peter Lam Nov 06 '11 at 04:11