You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
538 B
Objective-C

#include "Test.h"
static BOOL deallocCalled = NO;
static const char* objc_setAssociatedObjectKey = "objc_setAssociatedObjectKey";
@interface Associated : Test
@end
@implementation Associated
-(void) dealloc
{
deallocCalled = YES;
[super dealloc];
}
@end
int main(void)
{
@autoreleasepool {
Associated *object = [Associated new];
Test *holder = [[Test new] autorelease];
objc_setAssociatedObject(object, &objc_setAssociatedObjectKey, holder, OBJC_ASSOCIATION_RETAIN);
[object release];
}
assert(deallocCalled);
}