• 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: cocoa-dev digest, Vol 2 #3426 - 13 msgs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cocoa-dev digest, Vol 2 #3426 - 13 msgs


  • Subject: Re: cocoa-dev digest, Vol 2 #3426 - 13 msgs
  • From: Chuck Fleming <email@hidden>
  • Date: Sat, 3 Jan 2004 11:39:33 -0800

Hi,

Something like this should help.

Chuck

#import <Foundation/Foundation.h>
#import "Foo.h"
#import "/usr/include/objc/objc.h"
#import "/usr/include/objc/objc-class.h"
#import "/usr/include/objc/objc-runtime.h"

int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

Foo *foo;
struct objc_ivar *ivar;
struct objc_class *fooClass;
NSRect *rectAddress;

// foo has an ivar named "rect" of type NSRect
foo = [[Foo alloc] init];

fooClass = objc_getClass("Foo");
ivar = class_getInstanceVariable(fooClass, "rect");

// get a pointer to the ivar
rectAddress = (NSRect *)((void *)foo + ivar->ivar_offset);

// simple check
NSLog(@"rect = %@\n", NSStringFromRect(*rectAddress));

[pool release];
return 0;
}

On Jan 3, 2004, at 7:04 AM, email@hidden wrote:

>
> Message: 13
> Date: Sat, 03 Jan 2004 16:04:02 +0100
> From: Michael Monscheuer <email@hidden>
> To: cocoa-dev <email@hidden>
> Subject: object_getInstanceVariable() and non atomic var types
>
> To create an outline view showing a debugging view of a document model
> I
> am using object_getInstanceVariable() to read out the instance
> variables
> of objects.
> This works quite well if instance variable is of an atomic type (e.g.
> floats, ints, longs). But if an instance variable is some kind of
> stucture (e.g. NSRect, NSPoint) object_getInstanceVariable() returns
> just nothing.
>
> Any idea how to convert Rects etc. from an Ivar based instance var
> description back to a c type variable like object_getInstanceVariable()
> does correctly for atomic typed vars?
>
> MiMo
> --
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: OpenGL question
  • Next by Date: Re: OpenGL question
  • Previous by thread: Re: OpenGL question
  • Next by thread: my application's Help fails to appear
  • Index(es):
    • Date
    • Thread