<?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: Singleton Classes</title>
	<atom:link href="http://iphone.galloway.me.uk/iphone-sdktutorials/singleton-classes/feed/" rel="self" type="application/rss+xml" />
	<link>http://iphone.galloway.me.uk</link>
	<description>iPhone Applications</description>
	<lastBuildDate>Mon, 06 Feb 2012 20:55:13 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Flying Bug &#187; iOS development tips</title>
		<link>http://iphone.galloway.me.uk/iphone-sdktutorials/singleton-classes/comment-page-3/#comment-24413</link>
		<dc:creator>Flying Bug &#187; iOS development tips</dc:creator>
		<pubDate>Mon, 06 Feb 2012 20:55:13 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?page_id=137#comment-24413</guid>
		<description>[...] singleton &#8211; original post is here: * ios singleton class &#8211; idea * dig out the concept by yourself! * too much code, haven&#8217;t figured out what [...]</description>
		<content:encoded><![CDATA[<p>[...] singleton &#8211; original post is here: * ios singleton class &#8211; idea * dig out the concept by yourself! * too much code, haven&#8217;t figured out what [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Galloway</title>
		<link>http://iphone.galloway.me.uk/iphone-sdktutorials/singleton-classes/comment-page-3/#comment-24383</link>
		<dc:creator>Matt Galloway</dc:creator>
		<pubDate>Mon, 06 Feb 2012 11:00:06 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?page_id=137#comment-24383</guid>
		<description>@bearnun - You&#039;re trying to set it in the &lt;code&gt;@interface&lt;/code&gt; section of your class. That&#039;s entirely incorrect. The &lt;code&gt;@interface&lt;/code&gt; section is where you declare your instance variables but not set them up. You would set them up in your &lt;code&gt;init&lt;/code&gt; method usually. So something like:

[sourcecode lang=&quot;objc&quot;]
@implementation NewMeetMenu

- (id)init {
    if ((self = [super init])) {
        thisMatch = [Match thisMatch];
    }
    return self;
}

@end
[/sourcecode]</description>
		<content:encoded><![CDATA[<p>@bearnun &#8211; You&#8217;re trying to set it in the <code>@interface</code> section of your class. That&#8217;s entirely incorrect. The <code>@interface</code> section is where you declare your instance variables but not set them up. You would set them up in your <code>init</code> method usually. So something like:</p>
<pre class="brush: objc; title: ; notranslate">
@implementation NewMeetMenu

- (id)init {
    if ((self = [super init])) {
        thisMatch = [Match thisMatch];
    }
    return self;
}

@end
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: bearnun</title>
		<link>http://iphone.galloway.me.uk/iphone-sdktutorials/singleton-classes/comment-page-3/#comment-24353</link>
		<dc:creator>bearnun</dc:creator>
		<pubDate>Sun, 05 Feb 2012 22:06:59 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?page_id=137#comment-24353</guid>
		<description>Here&#039;s the fulle code for the file in which I try to call it: 

[sourcecode lang=&quot;objc&quot;]
#import 
#import &quot;Match.h&quot;
@class Cycle363;

@interface NewMeetMenu : UIViewController{
    IBOutlet UIScrollView *scroller;
    
    //Define textfields
    UITextField *meetField;
    UITextField *teamField;
    UITextField *stackerField;
    
    Match *thisMatch = [Match thisMatch];
}
//Properties of textfields
@property (nonatomic, strong) IBOutlet UITextField *meetField;
@property (nonatomic, strong) IBOutlet UITextField *teamField;
@property (nonatomic, strong) IBOutlet UITextField *stackerField;

//Properties of pop-up window
//@property (retain, nonatomic) UIWindow *window;
//@property (retain, nonatomic) Cycle363 *viewController;

//Methods to close the text-field keyboards when done
-(IBAction)meetFieldDone:(id)sender;
-(IBAction)teamFieldDone:(id)sender;
-(IBAction)stackerFieldDone:(id)sender;
[/sourcecode]</description>
		<content:encoded><![CDATA[<p>Here&#8217;s the fulle code for the file in which I try to call it: </p>
<pre class="brush: objc; title: ; notranslate">
#import
#import &quot;Match.h&quot;
@class Cycle363;

@interface NewMeetMenu : UIViewController{
    IBOutlet UIScrollView *scroller;

    //Define textfields
    UITextField *meetField;
    UITextField *teamField;
    UITextField *stackerField;

    Match *thisMatch = [Match thisMatch];
}
//Properties of textfields
@property (nonatomic, strong) IBOutlet UITextField *meetField;
@property (nonatomic, strong) IBOutlet UITextField *teamField;
@property (nonatomic, strong) IBOutlet UITextField *stackerField;

//Properties of pop-up window
//@property (retain, nonatomic) UIWindow *window;
//@property (retain, nonatomic) Cycle363 *viewController;

//Methods to close the text-field keyboards when done
-(IBAction)meetFieldDone:(id)sender;
-(IBAction)teamFieldDone:(id)sender;
-(IBAction)stackerFieldDone:(id)sender;
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Galloway</title>
		<link>http://iphone.galloway.me.uk/iphone-sdktutorials/singleton-classes/comment-page-3/#comment-24348</link>
		<dc:creator>Matt Galloway</dc:creator>
		<pubDate>Sun, 05 Feb 2012 17:04:29 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?page_id=137#comment-24348</guid>
		<description>@bearnun - Can you show the code that&#039;s calling &lt;code&gt;[Match thisMatch];&lt;/code&gt; at all? It sounds odd. I can&#039;t see anything wrong with how you&#039;ve done that.</description>
		<content:encoded><![CDATA[<p>@bearnun &#8211; Can you show the code that&#8217;s calling <code>[Match thisMatch];</code> at all? It sounds odd. I can&#8217;t see anything wrong with how you&#8217;ve done that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean</title>
		<link>http://iphone.galloway.me.uk/iphone-sdktutorials/singleton-classes/comment-page-3/#comment-24194</link>
		<dc:creator>Sean</dc:creator>
		<pubDate>Thu, 02 Feb 2012 20:13:14 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?page_id=137#comment-24194</guid>
		<description>release should be typed as oneway void, which allows the thread to not block in the case that you&#039;re doing distributed object message passing.</description>
		<content:encoded><![CDATA[<p>release should be typed as oneway void, which allows the thread to not block in the case that you&#8217;re doing distributed object message passing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bearnun</title>
		<link>http://iphone.galloway.me.uk/iphone-sdktutorials/singleton-classes/comment-page-3/#comment-24184</link>
		<dc:creator>bearnun</dc:creator>
		<pubDate>Thu, 02 Feb 2012 17:42:22 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?page_id=137#comment-24184</guid>
		<description>Sure!  I changed variable names a little to correspond to my code, but Match is &quot;MyManager&quot; basically.

[sourcecode lang=&quot;objc&quot;]
&quot;Match.h&quot;
#import 

@interface Match : NSObject {
    NSString *meetName;
}


//Corresponding getText from textFields
@property (nonatomic, copy) NSString *meetName;

+ (id)thisMatch;

@end

&quot;Match.m&quot;
#import &quot;Match.h&quot;

static Match *thisISMatch = nil;

@implementation Match

@dynamic meetName;

+ (id)thisMatch {
    @synchronized(self) {
        if (thisISMatch == nil)
            thisISMatch = [[self alloc] init];
    }
    return thisISMatch;
}

- (id)init {
    if (self = [super init]) {
        meetName = [[NSString alloc] initWithString:@&quot;Default Property Value&quot;];
    }
    return self;
}


@end
[/sourcecode]

Then I try to use the code by referencing the singleton in another class&#039;s header file:

Match *thisMatch = [Match thisMatch];

This is the line that is being troublesome.  The error I mentioned is on this equal sign.</description>
		<content:encoded><![CDATA[<p>Sure!  I changed variable names a little to correspond to my code, but Match is &#8220;MyManager&#8221; basically.</p>
<pre class="brush: objc; title: ; notranslate">
&quot;Match.h&quot;
#import 

@interface Match : NSObject {
    NSString *meetName;
}

//Corresponding getText from textFields
@property (nonatomic, copy) NSString *meetName;

+ (id)thisMatch;

@end

&quot;Match.m&quot;
#import &quot;Match.h&quot;

static Match *thisISMatch = nil;

@implementation Match

@dynamic meetName;

+ (id)thisMatch {
    @synchronized(self) {
        if (thisISMatch == nil)
            thisISMatch = [[self alloc] init];
    }
    return thisISMatch;
}

- (id)init {
    if (self = [super init]) {
        meetName = [[NSString alloc] initWithString:@&quot;Default Property Value&quot;];
    }
    return self;
}

@end
</pre>
<p>Then I try to use the code by referencing the singleton in another class&#8217;s header file:</p>
<p>Match *thisMatch = [Match thisMatch];</p>
<p>This is the line that is being troublesome.  The error I mentioned is on this equal sign.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Galloway</title>
		<link>http://iphone.galloway.me.uk/iphone-sdktutorials/singleton-classes/comment-page-3/#comment-24171</link>
		<dc:creator>Matt Galloway</dc:creator>
		<pubDate>Thu, 02 Feb 2012 09:24:51 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?page_id=137#comment-24171</guid>
		<description>@bearnun - Have you added &lt;code&gt;#import &quot;MyManager.h&quot;&lt;/code&gt; in the code that is using &lt;code&gt;MyManager&lt;/code&gt;? If that&#039;s not it then would you mind pasting a bit of code so I can maybe see what&#039;s going on?</description>
		<content:encoded><![CDATA[<p>@bearnun &#8211; Have you added <code>#import "MyManager.h"</code> in the code that is using <code>MyManager</code>? If that&#8217;s not it then would you mind pasting a bit of code so I can maybe see what&#8217;s going on?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bearnun</title>
		<link>http://iphone.galloway.me.uk/iphone-sdktutorials/singleton-classes/comment-page-3/#comment-24149</link>
		<dc:creator>bearnun</dc:creator>
		<pubDate>Thu, 02 Feb 2012 01:56:44 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?page_id=137#comment-24149</guid>
		<description>Hey, love the Singleton code.  

I tried emulating what you wrote in my code (ARC supported) but I&#039;m getting an &quot;Expected &#039;;&#039; at end of declaration list&quot; error on the singleton instantiation/declaration: MyManager *sharedManager = [MyManager sharedManager]; (The error is pointing at the equal&#039;s sign)

I&#039;m definitely not missing any semi-colons, do you have any idea what else might cause that error?</description>
		<content:encoded><![CDATA[<p>Hey, love the Singleton code.  </p>
<p>I tried emulating what you wrote in my code (ARC supported) but I&#8217;m getting an &#8220;Expected &#8216;;&#8217; at end of declaration list&#8221; error on the singleton instantiation/declaration: MyManager *sharedManager = [MyManager sharedManager]; (The error is pointing at the equal&#8217;s sign)</p>
<p>I&#8217;m definitely not missing any semi-colons, do you have any idea what else might cause that error?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Lehman</title>
		<link>http://iphone.galloway.me.uk/iphone-sdktutorials/singleton-classes/comment-page-3/#comment-21439</link>
		<dc:creator>Josh Lehman</dc:creator>
		<pubDate>Thu, 15 Dec 2011 03:30:37 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?page_id=137#comment-21439</guid>
		<description>Great summary. Really helped me put the singleton pattern into context for iOS.

One question... is there any issue with using a pattern like this to manage async communication with an outside web service? Being that the singleton is not really retained and only used for the intended process, does that process remain open to receive callbacks upon async completion of a process?

Thanks Matt!</description>
		<content:encoded><![CDATA[<p>Great summary. Really helped me put the singleton pattern into context for iOS.</p>
<p>One question&#8230; is there any issue with using a pattern like this to manage async communication with an outside web service? Being that the singleton is not really retained and only used for the intended process, does that process remain open to receive callbacks upon async completion of a process?</p>
<p>Thanks Matt!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Mazzotta</title>
		<link>http://iphone.galloway.me.uk/iphone-sdktutorials/singleton-classes/comment-page-3/#comment-20414</link>
		<dc:creator>Jason Mazzotta</dc:creator>
		<pubDate>Thu, 01 Dec 2011 02:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?page_id=137#comment-20414</guid>
		<description>Forget my last comment.  I wasn&#039;t reading the code correctly.  I replaced super in the factory method with the class name, which then does make it circular.  Thanks.</description>
		<content:encoded><![CDATA[<p>Forget my last comment.  I wasn&#8217;t reading the code correctly.  I replaced super in the factory method with the class name, which then does make it circular.  Thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

