[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
poseAsClass
From: |
Lloyd Dupont |
Subject: |
poseAsClass |
Date: |
Tue, 11 Apr 2006 17:59:50 +1000 |
Does poseAsClass work?
I tred to poseAsClass: NSObject to override release, but that doens't seems
to work.
I have a NSLOg in release, but it never write!.....
Below is my code:
static NSMutableDictionary * whoWasIt = nil;
@implementation DebugObject
+ (void) install
{
[self poseAsClass: [NSObject class]];
NSLog(@"DebugObject now posing as NSObject, watch out, NO OTHER OBJECT WILL
EVER BE RELEASED!");
}
- (void) release
{
NSLog(@"DebugObject release: 1");
if([self retainCount] > 1)
{
[super release];
return;
}
NSLog(@"DebugObject release: 2");
if([self isKindOfClass: [NSValue class]])
{
[super release];
return;
}
NSString * oldClassName = [self className];
self->isa = [DeadObject class];
NSLog(@"new isa: %p", self->isa);
if( whoWasIt == nil )
whoWasIt = [[NSMutableDictionary alloc] init];
[whoWasIt setObject: oldClassName forKey: [NSValue valueWithPointer:
self]];
}
@end
- poseAsClass,
Lloyd Dupont <=