9

Want to know the whole character set whose characters have to be escaped in an Objective-C NSString object in order to be recognized properly, e.g. " has to be escaped as \", as in

NSString *temporaryString = @"That book is dubbed as \"the little book\".";

Is the character set same with the one in C language char * string?

Thanks for your help :D

George
  • 3,384
  • 5
  • 40
  • 64

1 Answers1

14

The only characters that have to be escaped are the " (double-quote) and \ (backslash) characters.

There are other special character literals such as \n that have special meaning but those are really a separate issue.

Objective-C NSString values use the same set of special character literals as C.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • 4
    @neilb The `%` characters does not need to be escaped in an `NSString` literal unless you are talking about in a format string. But the question isn't about format strings. – rmaddy Oct 21 '14 at 05:00