On Oct 8, 2010, at 9:18 PM, Dave Keck wrote:
>> object_setIvar() takes type id.
>
> object_getInstanceVariable()?
>
> "outValue: On return, contains a pointer to the value of the instance
> variable."
Don't do that. object_getInstanceVariable() and object_setInstanceVariable()
still assume the ivar is of an object pointer type.
Instead, use class_getInstanceVariable() and ivar_getOffset() and pointer
arithmetic.
Ivar ivar = class_getInstanceVariable([YourClass class], "YourIvarName");
assert(ivar);
int *ivarPtr = (int *)((uint8_t *)obj + ivar_getOffset(ivar));
*ivarPtr = 42;
--
Greg Parker [email protected] Runtime Wrangler
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]