[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Test fro overridden method
From: |
Fred Kiefer |
Subject: |
Test fro overridden method |
Date: |
Fri, 29 Dec 2006 02:26:19 +0100 |
User-agent: |
Thunderbird 1.5.0.8 (X11/20060911) |
Could somebody please verify that this method does what I expect it to do?
I need such a test within NSDocument. Here Apple takes special care that
if somebody has implemented the old interface methods for NSDocument in
a subclass, then these methods are actually called instead of the new
interface methods.
/*
* Private helper method to check, if the method given via the selector sel
* has been overridden in the current subclass.
*/
- (BOOL)_hasOverridden: (SEL)sel
{
// The actual signature is not important as we wont call the methods.
IMP meth1;
IMP meth2;
meth1 = [self methodForSelector: sel];
meth2 = [[NSDocument class] instanceMethodForSelector: sel];
return (meth1 != meth2);
}
If the code stays that simple, I might even make a macro of it.
Cheers,
Fred
- Test fro overridden method,
Fred Kiefer <=