Set String with quotes to label in objective C programming?

Go To StackoverFlow.com

0

trackLbl2.text = @""Nonstop Bollywood Music"";

I try this but not working. How to text with double quotes.

2012-04-04 06:26
by NoName
Why did you not search anything before posting question?? Did you read this FAQ - rohan-patel 2012-04-04 06:30
Do not feel bad. But duplicate questions will just create unnecessary pile on website and headache for moderators. Though a very warm welcome from StackOverflow to you on behalf of every members - rohan-patel 2012-04-04 06:47


5

Try this:

 trackLbl2.text = @"\"Nonstop Bollywood Music\"";

You have to put \ before any special character to print it out.

2012-04-04 06:27
by rohan-patel


2

The user before me provided a good answer, but I would like to elaborate on your problem a little bit. It's a good thing to know.

In most (all?) programming languages, certain characters usually serve a special function - single quotes, double quotes, backslashes, and the likes. If you want to include those inside a string, the common practice is to "escape" them, or use escape characters. Escape characters are special character combinations that get replaced with the actual character you want to see inside the string; they usually start with a forward slash (\)*.

Here is a list of common escape characters used in Objective C (source: Wikipedia)
\a - Sound alert
\b - Backspace
\f - Form feed
\n - New line
\r - Carriage return
\t - Horizontal tab
\v - Vertical tab
\ - Backslash
\" - Double quote (used when placing a double quote into a string declaration)
\' - Single quote (used when placing a double quote into a string declaration)

Fun fact: I actually had to escape that forward slash in there by typing "\\".

2012-04-04 06:35
by Argent
Much appreciated for improvising.. :-)) + - rohan-patel 2012-04-04 06:39
Always glad to help - Argent 2012-04-04 06:44
Nice answer really good. - Kartik 2012-04-04 12:22


0

Try this

trackLbl2.text = @"\"Nonstop Bollywood Music\"";

You have to put \ before any special character to print it out.

2015-12-10 14:38
by Harman
Ads