Note: A technical post follows. If you’re not interested in iPhone programming, you can safely ignore it.
Technical Analysis
An update to RogueSheep’s Postage app was recently rejected by Apple because of a supposed overriding of a private method in a category. Apple most likely used a static analyzer to determine this problem. As far as I can tell, Apple has a bug in their static analyzer.
Three20 adds a category method -previousViewController
to the UIKit class UIViewController
. According to RogueSheep:
The notice from Apple indicated that we had used a private method of
UIViewController
calledpreviousViewController
.
As far as I can tell, there is no private method in UIViewController
called -previousViewController
. There is, however, a private method on UINavigationController (a subclass of UIViewController) called -previousViewController
.
However, this should not be a problem. Subclasses of UIViewController
which implement -previousViewController
themselves will override the category method defined on UIViewController
by Three20. This includes UINavigationController
and whatever other Apple-defined subclasses exist for UIViewController
.
I have filed this as Radar #7414099 (rdar://7414099 for Apple employees). The test project is available at: CategoryBehavior.zip
Opinion
Ultimately, if my analysis is correct, this is just a bug. They happen. Static analyzers are especially difficult to get right, especially when the source isn’t available. This shouldn’t be read as an indictment of Apple, or of Apple’s intentions. They’re just trying to protect the user experience of their products and head off binary compatibility problems.
However, I personally think they’re going to have a difficult time trying to detect private methods with a static analyzer. They might have better luck doing analysis at runtime — checking the actual class hierarchy and interposing on method calls.
Meanwhile, there will be a lot of false positives caused by this, which is going to be frustrating for a lot of iPhone app developers.