Skip to content

Instantly share code, notes, and snippets.

@tjw
Created August 28, 2009 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjw/177259 to your computer and use it in GitHub Desktop.
Save tjw/177259 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@interface ExtraData : NSObject
@end
@implementation ExtraData
- (void)dealloc;
{
fprintf(stderr, "ExtraData %p deallocated\n", self);
[super dealloc];
}
@end
int main(int argc, char *argv[])
{
NSObject *owner = [[NSObject alloc] init];
ExtraData *data = [[ExtraData alloc] init];
static void *ExtraDataKey;
objc_setAssociatedObject(owner, &ExtraDataKey, data, OBJC_ASSOCIATION_RETAIN);
[data release];
fprintf(stderr, "Releasing owner...\n");
[owner release];
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment