Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we write " in nsstring?

I have to initialize string as "Rose" including Quotation Mark. How to write " in our string?

like image 547
Baby Groot Avatar asked Apr 05 '11 12:04

Baby Groot


People also ask

How do I append to NSString?

Once a string has been initialized using NSString, the only way to append text to the string is to create a new NSString object. While doing so, you can append string constants, NSString objects, and other values.

What does NSString mean?

A static, plain-text Unicode string object which you use when you need reference semantics or other Foundation-specific behavior.

Do I need to release NSString?

If you create an object using a method that begins with init, new, copy, or mutableCopy, then you own that object and are responsible for releasing it (or autoreleasing it) when you're done with it. If you create an object using any other method, that object is autoreleased, and you don't need to release it.

What is the difference between string and NSString?

Essentially, there is no difference between string and String (capital S) in C#. String (capital S) is a class in the . NET framework in the System namespace. The fully qualified name is System.


2 Answers

Escape the double quote with \

NSString *yourString = @"\"Rose\""; 
like image 62
curtisk Avatar answered Oct 26 '22 07:10

curtisk


Use the escape character: \

NSString *r = @"\"Rose\"";

You can find additional information about Escape character and String literal.

like image 30
Black Frog Avatar answered Oct 26 '22 08:10

Black Frog