<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Java Developer&#8217;s Guide to String Constants in Objective-C</title>
	<atom:link href="http://iPhoneDeveloperTips.com/objective-c/java-developers-guide-to-string-constants-in-objective-c.html/feed" rel="self" type="application/rss+xml" />
	<link>http://iPhoneDeveloperTips.com/objective-c/java-developers-guide-to-string-constants-in-objective-c.html</link>
	<description>Tips and Tricks for iPhone developers</description>
	<lastBuildDate>Thu, 29 Jul 2010 23:00:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: dnd</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/java-developers-guide-to-string-constants-in-objective-c.html/comment-page-1#comment-9526</link>
		<dc:creator>dnd</dc:creator>
		<pubDate>Fri, 12 Feb 2010 11:10:20 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=865#comment-9526</guid>
		<description>@Rodney

&gt;&gt; My experience is with J2ME/Java and CF/C#; in both of those platforms, String literals “add up” and should always be avoided.

I know this is an old post, but I came across it while googling for &#039;constants in objective c&#039;.  I can&#039;t speak for the other environments, but this is not true of Java.

String x = &quot;xxx&quot;;
String y = &quot;xxx;

will result in only one String object being created.  Both x and y will reference the same String object.</description>
		<content:encoded><![CDATA[<p>@Rodney</p>
<p>&gt;&gt; My experience is with J2ME/Java and CF/C#; in both of those platforms, String literals “add up” and should always be avoided.</p>
<p>I know this is an old post, but I came across it while googling for &#8216;constants in objective c&#8217;.  I can&#8217;t speak for the other environments, but this is not true of Java.</p>
<p>String x = &#8220;xxx&#8221;;<br />
String y = &#8220;xxx;</p>
<p>will result in only one String object being created.  Both x and y will reference the same String object.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hasnat</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/java-developers-guide-to-string-constants-in-objective-c.html/comment-page-1#comment-7006</link>
		<dc:creator>Hasnat</dc:creator>
		<pubDate>Mon, 23 Nov 2009 15:51:42 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=865#comment-7006</guid>
		<description>@david
yes you are correct
you can define in separate header file</description>
		<content:encoded><![CDATA[<p>@david<br />
yes you are correct<br />
you can define in separate header file</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stevebert</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/java-developers-guide-to-string-constants-in-objective-c.html/comment-page-1#comment-213</link>
		<dc:creator>stevebert</dc:creator>
		<pubDate>Thu, 05 Feb 2009 19:38:34 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=865#comment-213</guid>
		<description>You&#039;re not incurring any more expense importing 999 unused #defines just to get that one string constant.  The compiler does not incur any storage allocation just because a #define exists, it has to be used in the code being compiled and then it&#039;s only a pointer reference to a global DATA item where the string constant is stored.  

Of course if you&#039;re using the same .h file across multiple executables, of course each binary will contain a copy of the string constant, but you knew that already.  ;-)</description>
		<content:encoded><![CDATA[<p>You&#8217;re not incurring any more expense importing 999 unused #defines just to get that one string constant.  The compiler does not incur any storage allocation just because a #define exists, it has to be used in the code being compiled and then it&#8217;s only a pointer reference to a global DATA item where the string constant is stored.  </p>
<p>Of course if you&#8217;re using the same .h file across multiple executables, of course each binary will contain a copy of the string constant, but you knew that already.  ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stevebert</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/java-developers-guide-to-string-constants-in-objective-c.html/comment-page-1#comment-212</link>
		<dc:creator>stevebert</dc:creator>
		<pubDate>Thu, 05 Feb 2009 19:34:37 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=865#comment-212</guid>
		<description>There&#039;s nothing magic about #defines so including them all in a massive .h is fine.  The pre-processor will substitute the string constants and the compiler will correlate multiple instances of the same string constant.</description>
		<content:encoded><![CDATA[<p>There&#8217;s nothing magic about #defines so including them all in a massive .h is fine.  The pre-processor will substitute the string constants and the compiler will correlate multiple instances of the same string constant.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/java-developers-guide-to-string-constants-in-objective-c.html/comment-page-1#comment-211</link>
		<dc:creator>david</dc:creator>
		<pubDate>Thu, 05 Feb 2009 12:54:19 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=865#comment-211</guid>
		<description>so whats the conclusion..whats the better way to declare NSString constants across the application ?

-----------------------------------------------------------------------
I created a .h file and it contents look like

//myconstants.h
#define stringglobal1 @&quot;ssss&quot;
#define string2 @&quot;zzzz&quot;

#define kMywidth 123

//more than 50 constats are there
and in other files I am using #import myconstants.h
I am also importing this header file only for using  a single constant 
-----------------------------------------------------------------------

is it okay ?</description>
		<content:encoded><![CDATA[<p>so whats the conclusion..whats the better way to declare NSString constants across the application ?</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
I created a .h file and it contents look like</p>
<p>//myconstants.h<br />
#define stringglobal1 @&#8221;ssss&#8221;<br />
#define string2 @&#8221;zzzz&#8221;</p>
<p>#define kMywidth 123</p>
<p>//more than 50 constats are there<br />
and in other files I am using #import myconstants.h<br />
I am also importing this header file only for using  a single constant<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>is it okay ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/java-developers-guide-to-string-constants-in-objective-c.html/comment-page-1#comment-210</link>
		<dc:creator>david</dc:creator>
		<pubDate>Thu, 05 Feb 2009 12:48:25 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=865#comment-210</guid>
		<description>so whats the conclusion..whats the better way to declare NSString constants across the application ?

-----------------------------------------------------------------------
I created a .h file and it contents look like

//myconstants.h
#define stringglobal1 @&quot;ssss&quot;
#define string2 @&quot;zzzz&quot;

#define kMywidth 123

and in other files I am using #import myconstants.h
-----------------------------------------------------------------------

is it okay ?</description>
		<content:encoded><![CDATA[<p>so whats the conclusion..whats the better way to declare NSString constants across the application ?</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
I created a .h file and it contents look like</p>
<p>//myconstants.h<br />
#define stringglobal1 @&#8221;ssss&#8221;<br />
#define string2 @&#8221;zzzz&#8221;</p>
<p>#define kMywidth 123</p>
<p>and in other files I am using #import myconstants.h<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>is it okay ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stevebert</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/java-developers-guide-to-string-constants-in-objective-c.html/comment-page-1#comment-87</link>
		<dc:creator>stevebert</dc:creator>
		<pubDate>Wed, 29 Oct 2008 18:16:54 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=865#comment-87</guid>
		<description>I have no special insight into the workings of the compiler, but I think the compiler detects the use of @&quot;&quot; string constants and makes instances of an &quot;NSString-like&quot; object in the DATA section of the executable (note the low-address reference for the string).  I say NSString-like because this type of object can never be sent retain or release messages, so is probably not a 1st class NSString instance.  Repeated uses of the string are probably matched by hashing the string literal and matching to an existing instance of the constant.</description>
		<content:encoded><![CDATA[<p>I have no special insight into the workings of the compiler, but I think the compiler detects the use of @&#8221;" string constants and makes instances of an &#8220;NSString-like&#8221; object in the DATA section of the executable (note the low-address reference for the string).  I say NSString-like because this type of object can never be sent retain or release messages, so is probably not a 1st class NSString instance.  Repeated uses of the string are probably matched by hashing the string literal and matching to an existing instance of the constant.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rodney</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/java-developers-guide-to-string-constants-in-objective-c.html/comment-page-1#comment-86</link>
		<dc:creator>Rodney</dc:creator>
		<pubDate>Wed, 29 Oct 2008 17:25:02 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=865#comment-86</guid>
		<description>@Stevebert,

Thanks for the response.  I stand corrected.  It is interesting to see how different ObjC is compared to other languages.  My experience is with J2ME/Java and CF/C#; in both of those platforms, String literals &quot;add up&quot; and should always be avoided.  This is, yet again, an example of how Objective-C excels as a language for mobile application development.

I&#039;ll update the article to include your feedback.  Thanks again!
- Rodney</description>
		<content:encoded><![CDATA[<p>@Stevebert,</p>
<p>Thanks for the response.  I stand corrected.  It is interesting to see how different ObjC is compared to other languages.  My experience is with J2ME/Java and CF/C#; in both of those platforms, String literals &#8220;add up&#8221; and should always be avoided.  This is, yet again, an example of how Objective-C excels as a language for mobile application development.</p>
<p>I&#8217;ll update the article to include your feedback.  Thanks again!<br />
- Rodney</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Wetherill</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/java-developers-guide-to-string-constants-in-objective-c.html/comment-page-1#comment-85</link>
		<dc:creator>Steve Wetherill</dc:creator>
		<pubDate>Wed, 29 Oct 2008 16:43:54 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=865#comment-85</guid>
		<description>OK, answer is here:

http://www.gnustep.org/resources/documentation/Developer/Base/Reference/NSString.html#003000000000</description>
		<content:encoded><![CDATA[<p>OK, answer is here:</p>
<p><a href="http://www.gnustep.org/resources/documentation/Developer/Base/Reference/NSString.html#003000000000" rel="nofollow">http://www.gnustep.org/resources/documentation/Developer/Base/Reference/NSString.html#003000000000</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Wetherill</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/java-developers-guide-to-string-constants-in-objective-c.html/comment-page-1#comment-84</link>
		<dc:creator>Steve Wetherill</dc:creator>
		<pubDate>Wed, 29 Oct 2008 16:42:13 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=865#comment-84</guid>
		<description>That looks correct.

It might help to understand this if we could see what @&quot;some literal&quot; actually translates to in the code. Presumably this maps to some instance of a specialization of NSString. I have not looked this up, but is it as simple as the @ being a special macro? Do you know off-hand how that mapping occurs?</description>
		<content:encoded><![CDATA[<p>That looks correct.</p>
<p>It might help to understand this if we could see what @&#8221;some literal&#8221; actually translates to in the code. Presumably this maps to some instance of a specialization of NSString. I have not looked this up, but is it as simple as the @ being a special macro? Do you know off-hand how that mapping occurs?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
