<?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: Initializers</title>
	<atom:link href="http://iPhoneDeveloperTips.com/objective-c/initializers.html/feed" rel="self" type="application/rss+xml" />
	<link>http://iPhoneDeveloperTips.com/objective-c/initializers.html</link>
	<description>iOS Developer Tips, Tricks and Tutorials.</description>
	<lastBuildDate>Wed, 08 Feb 2012 06:31:16 -0600</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: John Muchow</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/initializers.html#comment-56068</link>
		<dc:creator>John Muchow</dc:creator>
		<pubDate>Tue, 19 Jul 2011 20:50:01 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=53#comment-56068</guid>
		<description>The syntax can be confusing. It is essentially calling [super init] and assigning to self. The if statement checks to see if the result is nil (that is, self is nil). 

Here is an equivalent that may make more sense:

&lt;pre lang=&quot;objc&quot;&gt;
self = [super init];
if(self) 
{
  ...
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>The syntax can be confusing. It is essentially calling [super init] and assigning to self. The if statement checks to see if the result is nil (that is, self is nil). </p>
<p>Here is an equivalent that may make more sense:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super init<span style="color: #002200;">&#93;</span>;
<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>self<span style="color: #002200;">&#41;</span> 
<span style="color: #002200;">&#123;</span>
  ...
<span style="color: #002200;">&#125;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Jai Prakash</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/initializers.html#comment-56066</link>
		<dc:creator>Jai Prakash</dc:creator>
		<pubDate>Tue, 19 Jul 2011 20:32:05 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=53#comment-56066</guid>
		<description>should it not be 

if (self== [super init]){

...

}</description>
		<content:encoded><![CDATA[<p>should it not be </p>
<p>if (self== [super init]){</p>
<p>&#8230;</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bruno</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/initializers.html#comment-45025</link>
		<dc:creator>Bruno</dc:creator>
		<pubDate>Mon, 28 Mar 2011 22:22:39 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=53#comment-45025</guid>
		<description>Can I use something like this?

- (id)init {
	if (!(self = [super init])) return nil;
    self.isSpecial  = NO;
    self.index      = -1;
    self.week       = -1;
    self.images     = [[NSMutableArray alloc] initWithCapacity:25];
    self.menu       = [[NSMutableArray alloc] initWithCapacity:25];
    self.tip        = [[NSString alloc] init];
	return self;
}

- (id)initWithAttributesIsSpecial:(BOOL)_isSpecial 
                            index:(int)_index 
                             week:(int)_week 
                           images:(NSArray *)_images 
                             menu:(NSArray *)_menu 
                              tip:(NSString *)_tip {
    id _day = [[self init] autorelease];
    self.isSpecial  = _isSpecial;
    self.index      = _index;
    self.week       = _week;
    [_day addImages:_images];
    [_day addRecipes:_menu];
    self.tip        = _tip;
    r</description>
		<content:encoded><![CDATA[<p>Can I use something like this?</p>
<p>- (id)init {<br />
	if (!(self = [super init])) return nil;<br />
    self.isSpecial  = NO;<br />
    self.index      = -1;<br />
    self.week       = -1;<br />
    self.images     = [[NSMutableArray alloc] initWithCapacity:25];<br />
    self.menu       = [[NSMutableArray alloc] initWithCapacity:25];<br />
    self.tip        = [[NSString alloc] init];<br />
	return self;<br />
}</p>
<p>- (id)initWithAttributesIsSpecial:(BOOL)_isSpecial<br />
                            index:(int)_index<br />
                             week:(int)_week<br />
                           images:(NSArray *)_images<br />
                             menu:(NSArray *)_menu<br />
                              tip:(NSString *)_tip {<br />
    id _day = [[self init] autorelease];<br />
    self.isSpecial  = _isSpecial;<br />
    self.index      = _index;<br />
    self.week       = _week;<br />
    [_day addImages:_images];<br />
    [_day addRecipes:_menu];<br />
    self.tip        = _tip;<br />
    r</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Archimedes Trajano</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/initializers.html#comment-17759</link>
		<dc:creator>Archimedes Trajano</dc:creator>
		<pubDate>Tue, 22 Jun 2010 14:47:12 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=53#comment-17759</guid>
		<description>I am playing around with it, what I ended up doing was:

initWithStr: (NSString*)str;
initWithStr: (NSString*)str andDate: (NSDate*)date

that way when you invoke it it would look like:

initWithStr: @&quot;ABC&quot; andDate: date</description>
		<content:encoded><![CDATA[<p>I am playing around with it, what I ended up doing was:</p>
<p>initWithStr: (NSString*)str;<br />
initWithStr: (NSString*)str andDate: (NSDate*)date</p>
<p>that way when you invoke it it would look like:</p>
<p>initWithStr: @&#8221;ABC&#8221; andDate: date</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: geowar</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/initializers.html#comment-437</link>
		<dc:creator>geowar</dc:creator>
		<pubDate>Thu, 02 Apr 2009 01:49:47 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=53#comment-437</guid>
		<description>What if you have initializers like:

-(id)init;
-(id)initWithFD:(int)inFD;
-(id)initWithPath( const char * filepath );

where the initWithPath implementation would call open and (if successful) call initWithFD which could mmap the file and (if successful) call init?</description>
		<content:encoded><![CDATA[<p>What if you have initializers like:</p>
<p>-(id)init;<br />
-(id)initWithFD:(int)inFD;<br />
-(id)initWithPath( const char * filepath );</p>
<p>where the initWithPath implementation would call open and (if successful) call initWithFD which could mmap the file and (if successful) call init?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stompy</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/initializers.html#comment-22</link>
		<dc:creator>stompy</dc:creator>
		<pubDate>Sun, 17 Aug 2008 01:13:19 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=53#comment-22</guid>
		<description>@funkyboy

I&#039;d suggest a different method:

set up a designated initializer 

- init (parameter p1, parameter p2)

and have your initialisers call this initialiser with default values for the parameters not passed in.</description>
		<content:encoded><![CDATA[<p>@funkyboy</p>
<p>I&#8217;d suggest a different method:</p>
<p>set up a designated initializer </p>
<p>- init (parameter p1, parameter p2)</p>
<p>and have your initialisers call this initialiser with default values for the parameters not passed in.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: funkyboy</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/initializers.html#comment-21</link>
		<dc:creator>funkyboy</dc:creator>
		<pubDate>Thu, 14 Aug 2008 01:12:13 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=53#comment-21</guid>
		<description>Hi,

very interesting post! And also interesting web site initiative.
One question (I struggled with):

What if my domain is modeled in a way that there is:

- init (no parameters)
- init (a parameter p1)
- init (a parameter p2)

is it p1 to call p2 or viceversa?

Thanks,</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>very interesting post! And also interesting web site initiative.<br />
One question (I struggled with):</p>
<p>What if my domain is modeled in a way that there is:</p>
<p>- init (no parameters)<br />
- init (a parameter p1)<br />
- init (a parameter p2)</p>
<p>is it p1 to call p2 or viceversa?</p>
<p>Thanks,</p>
]]></content:encoded>
	</item>
</channel>
</rss>

