The runtime will happily add the methods to NSDate
, but the compiler will error out if you try to send a message that it hasn't seen declared.*
So as long as you import the header, your class will be able to use your new methods.
If you're talking about "overriding" a framework class's methods in a category, you should be aware that every use of that method in your process will use the new version. So if you clobber +[NSDate date]
, even Cocoa-internal calls to date
will use your version.** This can easily result in weird, even dangerous behavior. You should prefer mocking to this kind of clobbering.
Also note that, because of this phenomenon, you should always prefix methods that you add to framework classes via categories.
*Under ARC, at least.
**Assuming that date
was not originally itself implemented in a category; in that case, the results are "undefined behavior".