struct pointers

1 view
Skip to first unread message

Elizabeth Kellner

unread,
Aug 20, 2009, 1:28:20 PM8/20/09
to program...@googlegroups.com
Is there a way to use a pointer to a struct (NuPointer perhaps?) and, if you know the size of the fields, extract them?

in other words
typedef struct {
  int a;
  double b;
} MyStruct;

to get the value b out of a (MyStruct*)?

I could create a objc class to wrap the struct, but I am resistant to this; I think it's less clear to have a class and non-class version of the same data structure.  The original struct is in mapped memory and I would like to keep it as simple as possible. 

Thanks for your input
Elizabeth

Tim Burks

unread,
Aug 21, 2009, 12:08:57 AM8/21/09
to program...@googlegroups.com

I haven't built it, but I'd like to solve this problem with a general-
purpose pointer wrapper that uses Objective-C type signatures to
access and modify elements of structures.

I would imagine that it would take a signature in its constructor and
use something like key paths to identify elements.

That might be too big a project to write in your current situation,
but if you start with an ObjC class that wraps your struct, that class
could probably be evolved into a more general tool over time.

Tim
Reply all
Reply to author
Forward
0 new messages