Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-10-2010, 11:39 AM   #3 (permalink)
smasher
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

These are all valid ways to split a string across multiple lines:

Code:
	NSString *s = @"this" \
		@" is a" \
		@" very long" \
		@" string!";
	
	NSLog(s);
	
	
	NSString *s1 = @"this" 
		@" is a" 
		@" very long" 
		@" string!";
	
	NSLog(s1);
	
	NSString *s2 = @"this"
		" is a"
		" very long"
		" string!";
	
	NSLog(s2);
	
	NSString *s3 = @"this\
 is a\
 very long\
 string!";
	
	NSLog(s3);
The last one is probably the worst; it's hardest to understand what's in the string and what isn't, and it will break your indenting.

I prefer this one:
Code:
	NSString *s2 = @"this"
		" is a"
		" very long"
		" string!";
It's short and sweet. They all do the same thing, though.
__________________

Free Games!
smasher is offline   Reply With Quote
 

» Advertisements
» Online Users: 794
21 members and 773 guests
apatsufas, AppAnnex, armmzz, chenpo, Domele, erikmcmullan, falco1973, headkaze, jarv, Kirkout, Lily.P, lzwasyc, mapiko, Paul Slocum, pbart, PtSy, samball, Sami Gh, srhasan, walex, Wikiboo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,469
Threads: 94,037
Posts: 402,620
Top Poster: BrianSlick (7,978)
Welcome to our newest member, erikmcmullan
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:57 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.