Re: [Pyobjc-dev] how to use: NSValue_valueWithBytes_objCType_ ?
Brought to you by:
ronaldoussoren
From: Dirk S. <dir...@ma...> - 2006-01-09 10:41:22
|
On 7-jan-2006, at 0:22, Bob Ippolito wrote: > On Jan 6, 2006, at 2:11 PM, Dirk Stoop wrote: > >> I'm trying to use NSValue_valueWithBytes_objCType_, >> [...] >> >> I can't find anything on using NSValue_valueWithBytes_objCType in >> the docs, the list or basically anywhere, maybe someone here can >> give me a pointer in the right direction? > > You need to use the raw type encodings. @encode is a compiler > feature that isn't available at runtime... there might be a way to > introspect the NSRect wrapper in order to get its type encoding, > but I don't know it off the top of my head. > > The relevant docs are here: > http://developer.apple.com/documentation/Cocoa/Conceptual/ > ObjectiveC/RuntimeOverview/chapter_5_section_6.html > > Correct code looks something like this: > NSValue.valueWithBytes_objCType_(theRect, "{_NSRect={_NSPoint=ff} > {_NSSize=ff}}") > > > The "easiest" way to find a type encoding is to compile and run a > small Objective-C program like this: > > /* > main.m > */ > #include <Cocoa/Cocoa.h> > int main(int argc, char **argv) { > printf("%s\n", @encode(NSRect)); > return 0; > } > > % cc -o main main.m && ./main > {_NSRect={_NSPoint=ff}{_NSSize=ff}} > > -bob > Thanks Bob, I'm beginning to understand how it works now :-) Dirk |