<?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: Does Objective-C Perform Autoboxing on Primitives?</title>
	<atom:link href="http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/</link>
	<description>Taglines are for Windows programmers</description>
	<lastBuildDate>Mon, 26 Jul 2010 16:50:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Marcus Zarra</title>
		<link>http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/comment-page-1/#comment-727</link>
		<dc:creator>Marcus Zarra</dc:creator>
		<pubDate>Wed, 02 Jul 2008 16:12:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/#comment-727</guid>
		<description>&lt;p&gt;Yes, I need to do so, just have not had a chance to yet.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Yes, I need to do so, just have not had a chance to yet.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: drewmccormack</title>
		<link>http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/comment-page-1/#comment-726</link>
		<dc:creator>drewmccormack</dc:creator>
		<pubDate>Wed, 02 Jul 2008 08:57:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/#comment-726</guid>
		<description>&lt;p&gt;Hi Marcus,&lt;/p&gt;

&lt;p&gt;I have done some testing of my own, and this does not work. I have also heard it does not work from people in Apple.
I suggest removing the story,  or at the very least putting a big warning at the top that it is not accurate.
I started using this trick in my own code, only to find it was introducing subtle bugs.&lt;/p&gt;

&lt;p&gt;Drew&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi Marcus,</p>

<p>I have done some testing of my own, and this does not work. I have also heard it does not work from people in Apple.
I suggest removing the story,  or at the very least putting a big warning at the top that it is not accurate.
I started using this trick in my own code, only to find it was introducing subtle bugs.</p>

<p>Drew</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Marcus Zarra</title>
		<link>http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/comment-page-1/#comment-543</link>
		<dc:creator>Marcus Zarra</dc:creator>
		<pubDate>Mon, 14 Apr 2008 00:45:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/#comment-543</guid>
		<description>&lt;p&gt;Rob,&lt;/p&gt;

&lt;p&gt;I definitely share your discomfort with passing in a BOOL that way.  It is certainly not very pretty.&lt;/p&gt;

&lt;p&gt;As for this post, I have been mulling over it for quite a while now.  When I wrote it, I was 100% certain that it worked.  However, since posting it, I have received several code samples and comments showing me that it does not in fact work.&lt;/p&gt;

&lt;p&gt;I have been wrapped up with other projects and have not had a chance to give it the attention it is due.  I suspect that I will be posting a retraction of this article in the near future.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Rob,</p>

<p>I definitely share your discomfort with passing in a BOOL that way.  It is certainly not very pretty.</p>

<p>As for this post, I have been mulling over it for quite a while now.  When I wrote it, I was 100% certain that it worked.  However, since posting it, I have received several code samples and comments showing me that it does not in fact work.</p>

<p>I have been wrapped up with other projects and have not had a chance to give it the attention it is due.  I suspect that I will be posting a retraction of this article in the near future.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Rob Keniger</title>
		<link>http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/comment-page-1/#comment-542</link>
		<dc:creator>Rob Keniger</dc:creator>
		<pubDate>Sun, 13 Apr 2008 22:59:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/#comment-542</guid>
		<description>&lt;p&gt;I can&#039;t get this to work if I use an NSNumber. In my case I am calling a method that takes a BOOL argument:&lt;/p&gt;

&lt;p&gt;-(void) makeTargetFieldFirstResponder:(BOOL) becomeFirstResponder&lt;/p&gt;

&lt;p&gt;If I call it like this it fails to pass the becomeFirstResponder argument:&lt;/p&gt;

&lt;p&gt;[self performSelector:@selector(makeTargetFieldFirstResponder:) withObject:[NSNumber numberWithBool:YES] afterDelay:duration];&lt;/p&gt;

&lt;p&gt;However, if I do this it works fine:&lt;/p&gt;

&lt;p&gt;[self performSelector:@selector(makeTargetFieldFirstResponder:) withObject:(id)YES afterDelay:duration];&lt;/p&gt;

&lt;p&gt;I must say I&#039;m not really comfortable with this, it seems like taking advantage of a fluke of the language implementation rather than being correct. It&#039;s a shame the Apple documentation is so sparse in this area.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I can&#8217;t get this to work if I use an NSNumber. In my case I am calling a method that takes a BOOL argument:</p>

<p>-(void) makeTargetFieldFirstResponder:(BOOL) becomeFirstResponder</p>

<p>If I call it like this it fails to pass the becomeFirstResponder argument:</p>

<p>[self performSelector:@selector(makeTargetFieldFirstResponder:) withObject:[NSNumber numberWithBool:YES] afterDelay:duration];</p>

<p>However, if I do this it works fine:</p>

<p>[self performSelector:@selector(makeTargetFieldFirstResponder:) withObject:(id)YES afterDelay:duration];</p>

<p>I must say I&#8217;m not really comfortable with this, it seems like taking advantage of a fluke of the language implementation rather than being correct. It&#8217;s a shame the Apple documentation is so sparse in this area.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: markd</title>
		<link>http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/comment-page-1/#comment-57</link>
		<dc:creator>markd</dc:creator>
		<pubDate>Fri, 14 Mar 2008 22:09:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/#comment-57</guid>
		<description>&lt;p&gt;And here&#039;s a link to the code in case extracting it from the comments is annoying : http://borkware.com/hacks/autounbox.m&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>And here&#8217;s a link to the code in case extracting it from the comments is annoying : <a href="http://borkware.com/hacks/autounbox.m" rel="nofollow">http://borkware.com/hacks/autounbox.m</a></p>]]></content:encoded>
	</item>
	<item>
		<title>By: markd</title>
		<link>http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/comment-page-1/#comment-56</link>
		<dc:creator>markd</dc:creator>
		<pubDate>Fri, 14 Mar 2008 22:00:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/#comment-56</guid>
		<description>&lt;p&gt;I can&#039;t get this to work either.  Here&#039;s a little app that sends an NSNumber* to a method that takes an int via performSelectorOnMainThread.  (you&#039;ve got a little typo in the sample code, &quot;performSelector:&quot; rather than &quot;performSelectorOnMainThread:&quot;).  The NSLog seems to show that I&#039;m getting the address of the NSNumber rather than the unboxed value.  This is on Leopard 10.5.2.&lt;/p&gt;

&lt;p&gt;Here&#039;s the program:&lt;/p&gt;

&lt;h1&gt;import&lt;/h1&gt;

&lt;p&gt;/* compile with
gcc -g -Wall -framework Foundation -o autounbox autounbox.m
*/&lt;/p&gt;

&lt;p&gt;@interface Receiver : NSObject&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;(void) printGroovyness: (int)groovy;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;@end // Receiver&lt;/p&gt;

&lt;p&gt;@implementation Receiver&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;(void) printGroovyness: (int)groovy {
NSLog (@&quot;Groovy received: %x&quot;, groovy);
} // printGroovyness&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;@end // Receiver&lt;/p&gt;

&lt;p&gt;@interface Sender : NSObject
@end // Sender&lt;/p&gt;

&lt;p&gt;@implementation Sender&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;(void) boxingDay: (Receiver *)receiver {
[[NSAutoreleasePool alloc] init];&lt;/p&gt;

&lt;p&gt;int value = random() % 300;
NSNumber *number = [NSNumber numberWithInt: value];&lt;/p&gt;

&lt;p&gt;NSLog(@&quot;main-threading groovy of %d with pointer %p&quot;, value, number);&lt;/p&gt;

&lt;p&gt;[receiver performSelectorOnMainThread: @selector(printGroovyness:)
          withObject: number
          waitUntilDone: NO];&lt;/p&gt;

&lt;p&gt;sleep(10);&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;} // boxingDay&lt;/p&gt;

&lt;p&gt;@end // Sender&lt;/p&gt;

&lt;p&gt;int main (int argc, const char *argv[]) {
    [[NSAutoreleasePool alloc] init];&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Sender *sender = [[Sender alloc] init];
Receiver *receiver = [[Receiver alloc] init];

[NSThread detachNewThreadSelector: @selector(boxingDay:)
          toTarget: sender
          withObject: receiver];

// Give the runloop marklar a chance to catch its breath
sleep (1);
[[NSRunLoop mainRunLoop] run];

return (0);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;} // main&lt;/p&gt;

&lt;p&gt;and the output:&lt;/p&gt;

&lt;p&gt;2008-03-14 17:58:07.068 autounbox[2288:1003] main-threading groovy of 283 with pointer 0x20a720
2008-03-14 17:58:08.069 autounbox[2288:807] Groovy received: 20a720&lt;/p&gt;

&lt;p&gt;I&#039;d love to know what I&#039;m doing wrong, since this would simplify a primitive-type-passing situation I&#039;m in.&lt;/p&gt;

&lt;p&gt;Thanks!
++md&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I can&#8217;t get this to work either.  Here&#8217;s a little app that sends an NSNumber* to a method that takes an int via performSelectorOnMainThread.  (you&#8217;ve got a little typo in the sample code, &#8220;performSelector:&#8221; rather than &#8220;performSelectorOnMainThread:&#8221;).  The NSLog seems to show that I&#8217;m getting the address of the NSNumber rather than the unboxed value.  This is on Leopard 10.5.2.</p>

<p>Here&#8217;s the program:</p>

<h1>import</h1>

<p>/* compile with
gcc -g -Wall -framework Foundation -o autounbox autounbox.m
*/</p>

<p>@interface Receiver : NSObject</p>

<ul>
<li>(void) printGroovyness: (int)groovy;</li>
</ul>

<p>@end // Receiver</p>

<p>@implementation Receiver</p>

<ul>
<li>(void) printGroovyness: (int)groovy {
NSLog (@&#8221;Groovy received: %x&#8221;, groovy);
} // printGroovyness</li>
</ul>

<p>@end // Receiver</p>

<p>@interface Sender : NSObject
@end // Sender</p>

<p>@implementation Sender</p>

<ul>
<li><p>(void) boxingDay: (Receiver *)receiver {
[[NSAutoreleasePool alloc] init];</p>

<p>int value = random() % 300;
NSNumber *number = [NSNumber numberWithInt: value];</p>

<p>NSLog(@&#8221;main-threading groovy of %d with pointer %p&#8221;, value, number);</p>

<p>[receiver performSelectorOnMainThread: @selector(printGroovyness:)
          withObject: number
          waitUntilDone: NO];</p>

<p>sleep(10);</p></li>
</ul>

<p>} // boxingDay</p>

<p>@end // Sender</p>

<p>int main (int argc, const char *argv[]) {
    [[NSAutoreleasePool alloc] init];</p>

<pre><code>Sender *sender = [[Sender alloc] init];
Receiver *receiver = [[Receiver alloc] init];

[NSThread detachNewThreadSelector: @selector(boxingDay:)
          toTarget: sender
          withObject: receiver];

// Give the runloop marklar a chance to catch its breath
sleep (1);
[[NSRunLoop mainRunLoop] run];

return (0);
</code></pre>

<p>} // main</p>

<p>and the output:</p>

<p>2008-03-14 17:58:07.068 autounbox[2288:1003] main-threading groovy of 283 with pointer 0x20a720
2008-03-14 17:58:08.069 autounbox[2288:807] Groovy received: 20a720</p>

<p>I&#8217;d love to know what I&#8217;m doing wrong, since this would simplify a primitive-type-passing situation I&#8217;m in.</p>

<p>Thanks!
++md</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Wevah</title>
		<link>http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/comment-page-1/#comment-33</link>
		<dc:creator>Wevah</dc:creator>
		<pubDate>Tue, 04 Mar 2008 21:32:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/#comment-33</guid>
		<description>&lt;p&gt;Yeah, I currently call it from a background thread as-is, with no apparent ill effects, so I&#039;ll probably just leave as it is. I&#039;ll definitely test this out more as appropritate; it&#039;s no show-stopper for me, by any means.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Yeah, I currently call it from a background thread as-is, with no apparent ill effects, so I&#8217;ll probably just leave as it is. I&#8217;ll definitely test this out more as appropritate; it&#8217;s no show-stopper for me, by any means.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Marcus Zarra</title>
		<link>http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/comment-page-1/#comment-31</link>
		<dc:creator>Marcus Zarra</dc:creator>
		<pubDate>Mon, 03 Mar 2008 19:51:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/#comment-31</guid>
		<description>&lt;p&gt;I do not see anything wrong with that code.  I would ask:&lt;/p&gt;

&lt;p&gt;--is progressIndicator != nil?
--what happens when you call it directly without performSelectorOnMainThread?  You can probably call this from the background thread to test without the world coming to an end.&lt;/p&gt;

&lt;p&gt;That would be my suggestion because the auto-unboxing discussed above definitely works.  I use it all over the place in iWeb Buddy.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I do not see anything wrong with that code.  I would ask:</p>

<p>&#8211;is progressIndicator != nil?
&#8211;what happens when you call it directly without performSelectorOnMainThread?  You can probably call this from the background thread to test without the world coming to an end.</p>

<p>That would be my suggestion because the auto-unboxing discussed above definitely works.  I use it all over the place in iWeb Buddy.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Wevah</title>
		<link>http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/comment-page-1/#comment-30</link>
		<dc:creator>Wevah</dc:creator>
		<pubDate>Mon, 03 Mar 2008 19:45:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/#comment-30</guid>
		<description>&lt;p&gt;It&#039;s basically just:&lt;/p&gt;

&lt;p&gt;[progressIndicator performSelectorOnMainThread:@selector(incrementBy:) withObject:[NSNumber numberWithDouble:someDouble] waitUntilDone:YES]; // or waitUntilDone:NO, neither work for me&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>It&#8217;s basically just:</p>

<p>[progressIndicator performSelectorOnMainThread:@selector(incrementBy:) withObject:[NSNumber numberWithDouble:someDouble] waitUntilDone:YES]; // or waitUntilDone:NO, neither work for me</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Marcus Zarra</title>
		<link>http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/comment-page-1/#comment-29</link>
		<dc:creator>Marcus Zarra</dc:creator>
		<pubDate>Mon, 03 Mar 2008 17:12:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/#comment-29</guid>
		<description>&lt;p&gt;Wevah,&lt;/p&gt;

&lt;p&gt;Can you post what you are doing or send me an email with the lines of code you are working with?&lt;/p&gt;

&lt;p&gt;mzarra at mac dot com&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Wevah,</p>

<p>Can you post what you are doing or send me an email with the lines of code you are working with?</p>

<p>mzarra at mac dot com</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Wevah</title>
		<link>http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/comment-page-1/#comment-28</link>
		<dc:creator>Wevah</dc:creator>
		<pubDate>Mon, 03 Mar 2008 17:08:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/#comment-28</guid>
		<description>&lt;p&gt;Actually, in my limited testing, I can&#039;t seem to get this to work. I&#039;m calling the -incrementBy: method of an NSProgressIndicator, and it doesn&#039;t increment.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Actually, in my limited testing, I can&#8217;t seem to get this to work. I&#8217;m calling the -incrementBy: method of an NSProgressIndicator, and it doesn&#8217;t increment.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Wevah</title>
		<link>http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/comment-page-1/#comment-27</link>
		<dc:creator>Wevah</dc:creator>
		<pubDate>Mon, 03 Mar 2008 16:57:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/#comment-27</guid>
		<description>&lt;p&gt;This is good to know. I should be able to remove a few lines from some stuff nowâ€¦&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>This is good to know. I should be able to remove a few lines from some stuff nowâ€¦</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Andy Kim</title>
		<link>http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/comment-page-1/#comment-24</link>
		<dc:creator>Andy Kim</dc:creator>
		<pubDate>Mon, 03 Mar 2008 12:41:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/#comment-24</guid>
		<description>&lt;p&gt;Very nice! I wish I had known this sooner.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Very nice! I wish I had known this sooner.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: nevyn</title>
		<link>http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/comment-page-1/#comment-22</link>
		<dc:creator>nevyn</dc:creator>
		<pubDate>Sat, 01 Mar 2008 09:30:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/01/does-objective-c-perform-autoboxing-on-primitives/#comment-22</guid>
		<description>&lt;p&gt;Thanks! Did not know that.&lt;/p&gt;

&lt;p&gt;I have my own NCCommon.h that I can&#039;t live without. While we don&#039;t have automatic boxing, very short convenience method at least makes the code palatable. Behold:&lt;/p&gt;

&lt;p&gt;extern NSString* s(const char *str);&lt;/p&gt;

&lt;h1&gt;define sf(format, ...) ([NSString stringWithFormat: format, ##&lt;strong&gt;VA_ARGS&lt;/strong&gt;])&lt;/h1&gt;

&lt;p&gt;extern NSArray *ary(id item, ...);
extern NSDictionary *dict(id key, id value, ...);
extern NSNumber *num(double n);&lt;/p&gt;

&lt;p&gt;and NCCommon.m:
NSString* s(const char *str) {
    return [NSString stringWithUTF8String:str];
}
NSArray *ary(id item, ...) {
    if(!item) return [NSMutableArray array];
    NSMutableArray *ar = [NSMutableArray arrayWithObject:item];&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;va_list va;
va_start(va, item);
id obj = va_arg(va, id);
while(obj != nil) {
    [ar addObject:obj];
    obj = va_arg(va, id);
}
va_end(va);
return ar;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;NSDictionary *dict(id key, id value, ...) {
    if(!key) return [NSMutableDictionary dictionary];
    NSMutableDictionary *mdict = [NSMutableDictionary dictionaryWithObject:value forKey:key];&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;va_list va;
va_start(va, value);
id nextkey = va_arg(va, id);
id val = va_arg(va, id);
while(nextkey != nil &amp;&amp; val != nil) {
    [mdict setObject:val forKey:nextkey];
    nextkey = va_arg(va, id);
    val = va_arg(va, id);
}
va_end(va);
return mdict;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;NSNumber *num(double n) {
    return [NSNumber numberWithDouble:n];
}&lt;/p&gt;

&lt;p&gt;(yes, s and num could very well be defines as well... I blame it on being old code.)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks! Did not know that.</p>

<p>I have my own NCCommon.h that I can&#8217;t live without. While we don&#8217;t have automatic boxing, very short convenience method at least makes the code palatable. Behold:</p>

<p>extern NSString* s(const char *str);</p>

<h1>define sf(format, &#8230;) ([NSString stringWithFormat: format, ##<strong>VA_ARGS</strong>])</h1>

<p>extern NSArray *ary(id item, &#8230;);
extern NSDictionary *dict(id key, id value, &#8230;);
extern NSNumber *num(double n);</p>

<p>and NCCommon.m:
NSString* s(const char *str) {
    return [NSString stringWithUTF8String:str];
}
NSArray *ary(id item, &#8230;) {
    if(!item) return [NSMutableArray array];
    NSMutableArray *ar = [NSMutableArray arrayWithObject:item];</p>

<pre><code>va_list va;
va_start(va, item);
id obj = va_arg(va, id);
while(obj != nil) {
    [ar addObject:obj];
    obj = va_arg(va, id);
}
va_end(va);
return ar;
</code></pre>

<p>}</p>

<p>NSDictionary *dict(id key, id value, &#8230;) {
    if(!key) return [NSMutableDictionary dictionary];
    NSMutableDictionary *mdict = [NSMutableDictionary dictionaryWithObject:value forKey:key];</p>

<pre><code>va_list va;
va_start(va, value);
id nextkey = va_arg(va, id);
id val = va_arg(va, id);
while(nextkey != nil &amp;amp;&amp;amp; val != nil) {
    [mdict setObject:val forKey:nextkey];
    nextkey = va_arg(va, id);
    val = va_arg(va, id);
}
va_end(va);
return mdict;
</code></pre>

<p>}</p>

<p>NSNumber *num(double n) {
    return [NSNumber numberWithDouble:n];
}</p>

<p>(yes, s and num could very well be defines as well&#8230; I blame it on being old code.)</p>]]></content:encoded>
	</item>
</channel>
</rss>
