<?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: Objective-c Array Passing</title>
	<atom:link href="http://www.dbuggr.com/leothenerd/objective-array-passing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dbuggr.com/leothenerd/objective-array-passing/</link>
	<description>Share Knowledge &#38; Be Rewarded</description>
	<lastBuildDate>Fri, 03 Feb 2012 23:13:48 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: leothenerd</title>
		<link>http://www.dbuggr.com/leothenerd/objective-array-passing/comment-page-1/#comment-656</link>
		<dc:creator>leothenerd</dc:creator>
		<pubDate>Tue, 15 Dec 2009 02:08:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.dbuggr.com/leothenerd/objective-array-passing/#comment-656</guid>
		<description>you can pass a C array to a method:

&lt;code&gt;
- (void) ookie: (int *) snork {
    NSLog (@&quot;%d %d %d&quot;, snork[0], snork[1], snork[2]);
} // ookie
&lt;/code&gt;

Or use the [] syntax:

&lt;code&gt;
- (void) ookie2: (int[]) snork;
&lt;/code&gt;

or use the explicit size syntax (which doesn’t really matter for 1-D arrays):

&lt;code&gt;
- (void) ookie3: (int[17]) snork;
&lt;/code&gt;

And you can pass in pointers to pointers to pass back a resized array originally allocated by malloc:

&lt;code&gt;
- (void) ookie4: (int**) snork
         growTo: (int) elements {

    *snork = realloc(*snork, sizeof(int) * elements);
    (*snork)[0] = 55;

    NSLog (@&quot;(%d) %d %d %d&quot;, sizeof(snork), (*snork)[0], (*snork)[1], (*snork)[2]);

} // ookie4
&lt;/code&gt;

Passing in arrays of Objective-C types:

&lt;code&gt;
- (void) ookie: (NSString **) snork {
    NSLog (@&quot;%@ %@&quot;, snork[0], snork[1]);
} // ookie
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>you can pass a C array to a method:</p>
<p><pre><code>
- (void) ookie: (int *) snork {
&nbsp;&nbsp;&nbsp;&nbsp;NSLog (@&quot;%d %d %d&quot;, snork[0], snork[1], snork[2]);
} // ookie
</code></pre></p>
<p>Or use the [] syntax:</p>
<p><pre><code>
- (void) ookie2: (int[]) snork;
</code></pre></p>
<p>or use the explicit size syntax (which doesn’t really matter for 1-D arrays):</p>
<p><pre><code>
- (void) ookie3: (int[17]) snork;
</code></pre></p>
<p>And you can pass in pointers to pointers to pass back a resized array originally allocated by malloc:</p>
<p><pre><code>
- (void) ookie4: (int**) snork
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; growTo: (int) elements {

&nbsp;&nbsp;&nbsp;&nbsp;*snork = realloc(*snork, sizeof(int) * elements);
&nbsp;&nbsp;&nbsp;&nbsp;(*snork)[0] = 55;

&nbsp;&nbsp;&nbsp;&nbsp;NSLog (@&quot;(%d) %d %d %d&quot;, sizeof(snork), (*snork)[0], (*snork)[1], (*snork)[2]);

} // ookie4
</code></pre></p>
<p>Passing in arrays of Objective-C types:</p>
<p><pre><code>
- (void) ookie: (NSString **) snork {
&nbsp;&nbsp;&nbsp;&nbsp;NSLog (@&quot;%@ %@&quot;, snork[0], snork[1]);
} // ookie
</code></pre></p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
