<?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: Categories</title>
	<atom:link href="http://iPhoneDeveloperTips.com/objective-c/categories.html/feed" rel="self" type="application/rss+xml" />
	<link>http://iPhoneDeveloperTips.com/objective-c/categories.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: DD</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/categories.html#comment-63517</link>
		<dc:creator>DD</dc:creator>
		<pubDate>Mon, 28 Nov 2011 12:11:51 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=56#comment-63517</guid>
		<description>I&#039;m new to the Objective-C programming, but as I can see both from my experiments in XCode 4.2.1 and from &quot;Programming in Objective-C 2.0&quot; by S. Kochan, when overriding some method in a category, developer is NOT able to execute a method from the parent class by using a &#039;super&#039; keyword. 

Please correct me if I&#039;m wrong.</description>
		<content:encoded><![CDATA[<p>I&#8217;m new to the Objective-C programming, but as I can see both from my experiments in XCode 4.2.1 and from &#8220;Programming in Objective-C 2.0&#8243; by S. Kochan, when overriding some method in a category, developer is NOT able to execute a method from the parent class by using a &#8216;super&#8217; keyword. </p>
<p>Please correct me if I&#8217;m wrong.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Betsey Ostorga</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/categories.html#comment-58011</link>
		<dc:creator>Betsey Ostorga</dc:creator>
		<pubDate>Mon, 15 Aug 2011 11:10:20 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=56#comment-58011</guid>
		<description>Hi, thanks for this comment :)</description>
		<content:encoded><![CDATA[<p>Hi, thanks for this comment :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Muchow</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/categories.html#comment-54596</link>
		<dc:creator>John Muchow</dc:creator>
		<pubDate>Fri, 01 Jul 2011 16:33:07 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=56#comment-54596</guid>
		<description>Seems Xcode treats filenames as case-insensitive. Either way, it was a typo on my end - I&#039;ve fixed and uploaded a new version of the project.

John</description>
		<content:encoded><![CDATA[<p>Seems Xcode treats filenames as case-insensitive. Either way, it was a typo on my end &#8211; I&#8217;ve fixed and uploaded a new version of the project.</p>
<p>John</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/categories.html#comment-54481</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Thu, 30 Jun 2011 06:58:06 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=56#comment-54481</guid>
		<description>About the file name in the project. They are

NSString+reverse.h                                   (NOT NSString+Reverse.h)
NSString+Reverse.m

In the NSString+Reverse.m we see
#import &quot;NSString+Reverse.h&quot;                 (NOT NSString+reverse.h)

However, it works. Why?

Alex</description>
		<content:encoded><![CDATA[<p>About the file name in the project. They are</p>
<p>NSString+reverse.h                                   (NOT NSString+Reverse.h)<br />
NSString+Reverse.m</p>
<p>In the NSString+Reverse.m we see<br />
#import &#8220;NSString+Reverse.h&#8221;                 (NOT NSString+reverse.h)</p>
<p>However, it works. Why?</p>
<p>Alex</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stef13</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/categories.html#comment-36909</link>
		<dc:creator>stef13</dc:creator>
		<pubDate>Sat, 08 Jan 2011 10:08:54 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=56#comment-36909</guid>
		<description>Thanks for this explanation...</description>
		<content:encoded><![CDATA[<p>Thanks for this explanation&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick D</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/categories.html#comment-16258</link>
		<dc:creator>Nick D</dc:creator>
		<pubDate>Tue, 01 Jun 2010 05:51:04 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=56#comment-16258</guid>
		<description>@Leifur 

The Apple documentation actually states that it&#039;s a bad idea to use categories to override instance or class methods: http://developer.apple.com/mac/library/documentation/cocoa/conceptual/objectivec/articles/occategories.html

The relevant bit for you is the first bullet point in this section:

&quot;Although the language currently allows you to use a category to override methods the class inherits, or even methods declared in the class interface, you are strongly discouraged from using this functionality. A category is not a substitute for a subclass. There are several significant shortcomings:

    *      When a category overrides an inherited method, the method in the category can, as usual, invoke the inherited implementation via a message to super. However, if a category overrides a method that already existed in the category&#039;s class, there is no way to invoke the original implementation.

    *      A category cannot reliably override methods declared in another category of the same class.

      This issue is of particular significance since many of the Cocoa classes are implemented using categories. A framework-defined method you try to override may itself have been implemented in a category, and so which implementation takes precedence is not defined.

    *      The very presence of some methods may cause behavior changes across all frameworks. For example, if you add an implementation of windowWillClose: to NSObject, this will cause all window delegates to respond to that method and may modify the behavior of all instances of NSWindow instances. This may cause mysterious changes in behavior and can lead to crashes.&quot;

...hope that helps!
Nick</description>
		<content:encoded><![CDATA[<p>@Leifur </p>
<p>The Apple documentation actually states that it&#8217;s a bad idea to use categories to override instance or class methods: <a href="http://developer.apple.com/mac/library/documentation/cocoa/conceptual/objectivec/articles/occategories.html" rel="nofollow">http://developer.apple.com/mac/library/documentation/cocoa/conceptual/objectivec/articles/occategories.html</a></p>
<p>The relevant bit for you is the first bullet point in this section:</p>
<p>&#8220;Although the language currently allows you to use a category to override methods the class inherits, or even methods declared in the class interface, you are strongly discouraged from using this functionality. A category is not a substitute for a subclass. There are several significant shortcomings:</p>
<p>    *      When a category overrides an inherited method, the method in the category can, as usual, invoke the inherited implementation via a message to super. However, if a category overrides a method that already existed in the category&#8217;s class, there is no way to invoke the original implementation.</p>
<p>    *      A category cannot reliably override methods declared in another category of the same class.</p>
<p>      This issue is of particular significance since many of the Cocoa classes are implemented using categories. A framework-defined method you try to override may itself have been implemented in a category, and so which implementation takes precedence is not defined.</p>
<p>    *      The very presence of some methods may cause behavior changes across all frameworks. For example, if you add an implementation of windowWillClose: to NSObject, this will cause all window delegates to respond to that method and may modify the behavior of all instances of NSWindow instances. This may cause mysterious changes in behavior and can lead to crashes.&#8221;</p>
<p>&#8230;hope that helps!<br />
Nick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sebastian</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/categories.html#comment-15655</link>
		<dc:creator>Sebastian</dc:creator>
		<pubDate>Fri, 21 May 2010 23:25:00 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=56#comment-15655</guid>
		<description>Thank you! 
With this perfect explanation i just managed my write my first category that saves me typing when loading images in a imageview when &quot;imagenamed&quot; would clutter the ram / cache.
Thank you! Thank you! Thank you!</description>
		<content:encoded><![CDATA[<p>Thank you!<br />
With this perfect explanation i just managed my write my first category that saves me typing when loading images in a imageview when &#8220;imagenamed&#8221; would clutter the ram / cache.<br />
Thank you! Thank you! Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sascha Hameister</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/categories.html#comment-12125</link>
		<dc:creator>Sascha Hameister</dc:creator>
		<pubDate>Sun, 28 Mar 2010 06:04:16 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=56#comment-12125</guid>
		<description>Hey John,

I just a very efficient way to reverse a string and started with your lines of codes. Here is what I came up at the end. Hope this will help for some people. :-)

@implementation NSString (reverse)
- (NSString *) reverseString {
	NSMutableString *reversedStr;
	int len = [self length];
	
	// Auto released string
	reversedStr = [NSMutableString stringWithCapacity:len];     
	
	while (len--) {
		[reversedStr appendFormat:@&quot;%C&quot;, [self characterAtIndex:len]];
	}
	
	return reversedStr;
}</description>
		<content:encoded><![CDATA[<p>Hey John,</p>
<p>I just a very efficient way to reverse a string and started with your lines of codes. Here is what I came up at the end. Hope this will help for some people. :-)</p>
<p>@implementation NSString (reverse)<br />
- (NSString *) reverseString {<br />
	NSMutableString *reversedStr;<br />
	int len = [self length];</p>
<p>	// Auto released string<br />
	reversedStr = [NSMutableString stringWithCapacity:len];     </p>
<p>	while (len&#8211;) {<br />
		[reversedStr appendFormat:@"%C", [self characterAtIndex:len]];<br />
	}</p>
<p>	return reversedStr;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Sanchez</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/categories.html#comment-8875</link>
		<dc:creator>Mark Sanchez</dc:creator>
		<pubDate>Fri, 22 Jan 2010 02:17:45 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=56#comment-8875</guid>
		<description>F.Y.I. Posible Error with naming classes and use of categories.

I have used categories to breakup a class into multiple files with no problems in the past.  I tried to do the same with a class name (&quot;Game_2ViewController+Animation.h&quot;) that had an underscore character and the methods and functions defined within the subcategory class file could not be called by the program.  I simply made a new subcategory class file and used no underscore character (&quot;Game2ViewController+Animation.h&quot;) and the problem went away?</description>
		<content:encoded><![CDATA[<p>F.Y.I. Posible Error with naming classes and use of categories.</p>
<p>I have used categories to breakup a class into multiple files with no problems in the past.  I tried to do the same with a class name (&#8220;Game_2ViewController+Animation.h&#8221;) that had an underscore character and the methods and functions defined within the subcategory class file could not be called by the program.  I simply made a new subcategory class file and used no underscore character (&#8220;Game2ViewController+Animation.h&#8221;) and the problem went away?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Hohle</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/categories.html#comment-8635</link>
		<dc:creator>Jonathan Hohle</dc:creator>
		<pubDate>Tue, 12 Jan 2010 16:13:01 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=56#comment-8635</guid>
		<description>@Leifur Bjorn when you shadow a method with a category, you lose access to the original method. You can think of categories like adding items to a class or instance method dictionary. If you add a value for a key that already exists, you&#039;ll overwrite the existing value. (There are ways to get around this at runtime by saving the pointer to the old method, but not at compile time.)

To access the original method you must subclass.</description>
		<content:encoded><![CDATA[<p>@Leifur Bjorn when you shadow a method with a category, you lose access to the original method. You can think of categories like adding items to a class or instance method dictionary. If you add a value for a key that already exists, you&#8217;ll overwrite the existing value. (There are ways to get around this at runtime by saving the pointer to the old method, but not at compile time.)</p>
<p>To access the original method you must subclass.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

