<?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: Private Methods</title>
	<atom:link href="http://MacDeveloperTips.com/objective-c/private-methods.html/feed" rel="self" type="application/rss+xml" />
	<link>http://MacDeveloperTips.com/objective-c/private-methods.html</link>
	<description>Tips, tools and code for iPhone and Mac developers.</description>
	<lastBuildDate>Fri, 30 Jul 2010 22:59:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: john</title>
		<link>http://MacDeveloperTips.com/objective-c/private-methods.html/comment-page-1#comment-441</link>
		<dc:creator>john</dc:creator>
		<pubDate>Sun, 17 Aug 2008 01:38:55 +0000</pubDate>
		<guid isPermaLink="false">http://MacDeveloperTips.com/objective-c/objective-c-private-methods.html#comment-441</guid>
		<description>Comments are closed on this post. You can comment on this same post which has been moved to the iPhone Developer Tips blog: http://iphonedevelopertips.com/objective-c/private-methods.html</description>
		<content:encoded><![CDATA[<p>Comments are closed on this post. You can comment on this same post which has been moved to the iPhone Developer Tips blog: <a href="http://iphonedevelopertips.com/objective-c/private-methods.html" rel="nofollow">http://iphonedevelopertips.com/objective-c/private-methods.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stompy</title>
		<link>http://MacDeveloperTips.com/objective-c/private-methods.html/comment-page-1#comment-433</link>
		<dc:creator>stompy</dc:creator>
		<pubDate>Fri, 15 Aug 2008 08:25:53 +0000</pubDate>
		<guid isPermaLink="false">http://MacDeveloperTips.com/objective-c/objective-c-private-methods.html#comment-433</guid>
		<description>An alternative way to declare a private class method is described in the Objective-C 2.0 documentation.

If you are writing your own class, you can add private methods that are implemented directly within the main implementation block of the class by declaring an empty category. eg:

@interface MyObject : NSObject
{
    NSNumber *number;
}
- (NSNumber *)number;
@end
 
@interface MyObject ()
- (void)setNumber:(NSNumber *)newNumber;
@end
 
 
@implementation MyObject
 
- (NSNumber *)number
{
    return number;
}
- (void)setNumber(NSNumber *)newNumber
{
    number = newNumber;
}
@end

This way you don&#039;t have to write a separate @implementation block for the private methods. Probably best to use this for methods that are only used within the class itself.</description>
		<content:encoded><![CDATA[<p>An alternative way to declare a private class method is described in the Objective-C 2.0 documentation.</p>
<p>If you are writing your own class, you can add private methods that are implemented directly within the main implementation block of the class by declaring an empty category. eg:</p>
<p>@interface MyObject : NSObject<br />
{<br />
    NSNumber *number;<br />
}<br />
- (NSNumber *)number;<br />
@end</p>
<p>@interface MyObject ()<br />
- (void)setNumber:(NSNumber *)newNumber;<br />
@end</p>
<p>@implementation MyObject</p>
<p>- (NSNumber *)number<br />
{<br />
    return number;<br />
}<br />
- (void)setNumber(NSNumber *)newNumber<br />
{<br />
    number = newNumber;<br />
}<br />
@end</p>
<p>This way you don&#8217;t have to write a separate @implementation block for the private methods. Probably best to use this for methods that are only used within the class itself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bob</title>
		<link>http://MacDeveloperTips.com/objective-c/private-methods.html/comment-page-1#comment-330</link>
		<dc:creator>bob</dc:creator>
		<pubDate>Wed, 02 Jul 2008 12:53:08 +0000</pubDate>
		<guid isPermaLink="false">http://MacDeveloperTips.com/objective-c/objective-c-private-methods.html#comment-330</guid>
		<description>Change Main.m to include the following additional lines and the compiler warnings disappear.   This is an unfortunately common pattern used to expose private API that oft produces maintenance headaches in the future.

#import &quot;SomeClass.h&quot;

@interface SomeClass (ExposingThePrivateParts)
+(void) hiddenClassMethod;
-(void) hiddenInstanceMethod;
@end

int main (int argc, char *argv[])</description>
		<content:encoded><![CDATA[<p>Change Main.m to include the following additional lines and the compiler warnings disappear.   This is an unfortunately common pattern used to expose private API that oft produces maintenance headaches in the future.</p>
<p>#import &#8220;SomeClass.h&#8221;</p>
<p>@interface SomeClass (ExposingThePrivateParts)<br />
+(void) hiddenClassMethod;<br />
-(void) hiddenInstanceMethod;<br />
@end</p>
<p>int main (int argc, char *argv[])</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy Lee</title>
		<link>http://MacDeveloperTips.com/objective-c/private-methods.html/comment-page-1#comment-329</link>
		<dc:creator>Andy Lee</dc:creator>
		<pubDate>Wed, 02 Jul 2008 12:20:39 +0000</pubDate>
		<guid isPermaLink="false">http://MacDeveloperTips.com/objective-c/objective-c-private-methods.html#comment-329</guid>
		<description>I prefer the category approach as well, mainly because I like to put &quot;private&quot; methods at the end, but I agree it&#039;s a matter of preference.  Note that Ondra&#039;s approach only works if you can arrange your private methods in such a way that they are defined before they are called.  In rare cases, private method X calls private method Y, and method Y also calls method X.</description>
		<content:encoded><![CDATA[<p>I prefer the category approach as well, mainly because I like to put &#8220;private&#8221; methods at the end, but I agree it&#8217;s a matter of preference.  Note that Ondra&#8217;s approach only works if you can arrange your private methods in such a way that they are defined before they are called.  In rare cases, private method X calls private method Y, and method Y also calls method X.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: john</title>
		<link>http://MacDeveloperTips.com/objective-c/private-methods.html/comment-page-1#comment-328</link>
		<dc:creator>john</dc:creator>
		<pubDate>Wed, 02 Jul 2008 11:40:56 +0000</pubDate>
		<guid isPermaLink="false">http://MacDeveloperTips.com/objective-c/objective-c-private-methods.html#comment-328</guid>
		<description>Ondra (http://www.ocs.cz) has passed along another means to accomplish the same end result, without using categories:

@interface X:NSObject
-(void)published;
@end

@implementation X
-(void)unpublished { ... }
-(void)published { ... [self unpublished]; ... }
@end

The trick here, is that the unpublished method is not defined in the interface, yet there is an implementation of the method in the implementation section. The end result here is that you don&#039;t have two separate implementation sections.

I still prefer the idea of using categories as it make the implementation feel more akin to a publicly declared API (through SomeClass.h) and an additional (private) API for internal use by the class.

A personal preference to be sure...</description>
		<content:encoded><![CDATA[<p>Ondra (<a href="http://www.ocs.cz" rel="nofollow">http://www.ocs.cz</a>) has passed along another means to accomplish the same end result, without using categories:</p>
<p>@interface X:NSObject<br />
-(void)published;<br />
@end</p>
<p>@implementation X<br />
-(void)unpublished { &#8230; }<br />
-(void)published { &#8230; [self unpublished]; &#8230; }<br />
@end</p>
<p>The trick here, is that the unpublished method is not defined in the interface, yet there is an implementation of the method in the implementation section. The end result here is that you don&#8217;t have two separate implementation sections.</p>
<p>I still prefer the idea of using categories as it make the implementation feel more akin to a publicly declared API (through SomeClass.h) and an additional (private) API for internal use by the class.</p>
<p>A personal preference to be sure&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
