Why do CFType instances respond to NSObject messages?
Why do CFType instances respond to NSObject messages?
- Subject: Why do CFType instances respond to NSObject messages?
- From: Wilson Chen <email@hidden>
- Date: Thu, 16 Jul 2009 22:24:32 +1000
Hi all,
I'm new to the Cocoa framework, and puzzled why the following code would
work:
CGLayerRef layer = ...assume we have a layer created.
printf("Retain count after creation: %i\n", CFGetRetainCount(layer));
[(NSObject*)layer retain];
printf("Retain count after sending a retain message: %i\n",
CFGetRetainCount(layer));
[(NSObject*)layer release];
printf("Retain count after sending a release message: %i\n",
CFGetRetainCount(layer));
The code above gives the following output:
Retain count after creation: 1
Retain count after sending a retain message: 2
Retain count after sending a release message: 1
Since a CGLayer is not a subclass of NSObject, its instances shouldn't
respond to retain/release messages. Yet the code works.
ciao,
wils
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden