• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ivars and fundamental types
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ivars and fundamental types


  • Subject: Re: ivars and fundamental types
  • From: Greg Parker <email@hidden>
  • Date: Tue, 12 Oct 2010 10:32:20 -0700

On Oct 11, 2010, at 10:13 PM, Dave Keck wrote:
>> Don't do that. object_getInstanceVariable() and object_setInstanceVariable()
>> still assume the ivar is of an object pointer type.
>
> As the documentation and prototypes stand, one would think that
> object_getInstanceVariable() could be used like this:
>
>    double *doublePointer = nil;
>    object_getInstanceVariable(..., (void **)&doublePointer);
>    NSLog(@"%f", *doublePointer); // get ivar value
>    *doublePointer = 42.4242; // set ivar value (erroneously bypassing
> potential GC write barriers if it were a pointer type)
>
> ... especially since outValue is documented as "On return, contains a
> pointer to the value of the instance variable." In fact, I suppose it
> should read "On return, contains the value of a pointer-typed instance
> variable."

The function writes the ivar's value to *outValue. Please file a bug report if you don't like the documentation.


> Furthermore, if object_getInstanceVariable() assumes an "object
> pointer type" -- emphasis on _object_ -- shouldn't outValue be typed
> {id *}?

It happens to work for pointer-size non-object values. We'd probably deprecate it rather than changing the prototype at this point.


--
Greg Parker     email@hidden     Runtime Wrangler


_______________________________________________

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

References: 
 >ivars and fundamental types (From: Rick Mann <email@hidden>)
 >Re: ivars and fundamental types (From: Sherm Pendley <email@hidden>)
 >Re: ivars and fundamental types (From: Rick Mann <email@hidden>)
 >Re: ivars and fundamental types (From: Dave Keck <email@hidden>)
 >Re: ivars and fundamental types (From: Greg Parker <email@hidden>)
 >Re: ivars and fundamental types (From: Dave Keck <email@hidden>)

  • Prev by Date: Re: main window disappears on resize
  • Next by Date: Re: remove icon from Dock
  • Previous by thread: Re: ivars and fundamental types
  • Next by thread: SRV record lookup
  • Index(es):
    • Date
    • Thread