• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NEWBIE - What's the line continuation character
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NEWBIE - What's the line continuation character


  • Subject: Re: NEWBIE - What's the line continuation character
  • From: Nicko van Someren <email@hidden>
  • Date: Mon, 18 Jul 2005 11:51:26 +0100

On 18 Jul 2005, at 11:30, Jeff Brown wrote:

When continuing a string from one line to the next
(for readability),
what character do you use?

I think that all text inside a string is taken literally. That said, Objective-C supports the same automatic string concatenation at compile time that old fashioned C does, so you can do something like this:
NSString *s = @"This is a long string "
"which is spread across "
"several lines so as to "
"make it easier to read.";
At compile time the strings will be joined together into a single string object. Note also that the presence of the leading @ in front of the follow on strings is optional, so:
s = @"A game of " @"two halves";
also works to assign the single concatenated string into s. You don't even have to be consistent and can mix things up if you wish, which can be handy if someone else defined some string in a hash define, e.g.
#define MyString @"Yonder Mountain"
...
s = @"Save me from having to use stringWithFormat: for a constant in file " __FILE__ " referring to " MyString;
I hope this helps.


    Nicko

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NEWBIE - What's the line continuation character (From: Jeff Brown <email@hidden>)

  • Prev by Date: NEWBIE - What's the line continuation character
  • Next by Date: LSUIElement and hot keys
  • Previous by thread: NEWBIE - What's the line continuation character
  • Next by thread: LSUIElement and hot keys
  • Index(es):
    • Date
    • Thread