Re: Calling original method implementation from category
Re: Calling original method implementation from category
- Subject: Re: Calling original method implementation from category
- From: Stephane Sudre <email@hidden>
- Date: Mon, 25 Apr 2005 13:09:58 +0200
On 25 avr. 05, at 11:54, Georg Tuparev wrote:
On Apr 25, 2005, at 11:28 AM, Yann Bizeul wrote:
[...]
It is described in countless books, articles, online docs, and
postings. But someone have to read them :-)
Do you have any reference available explaining that you can override a
method with a category?
The documents I have read always use the terms: add a method, extend a
class, etc.
And for the record, here is what an override attempt gives:
#import <Foundation/Foundation.h>
@interface NSString (test)
- (unsigned int)length;
- (unsigned int)length2;
@end
@implementation NSString (test)
- (unsigned int)length
{
return 1;
}
- (unsigned int)length2
{
return 1;
}
@end
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString * testString=@"sgjfhjsgfhjsdgfhj";
NSLog(@"Length of %@ is: %u",testString,[testString length]);
// insert code here...
NSLog(@"Length2: %u",[testString length2]);
[pool release];
return 0;
}
Result:
Length of sgjfhjsgfhjsdgfhj is: 17
Length2: 1
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden