Encoding an integer in another object
Encoding an integer in another object
- Subject: Encoding an integer in another object
- From: Bertil Holmberg <email@hidden>
- Date: Wed, 04 Sep 2002 17:32:07 +0200
- Organization: MacMAS
I would like my Document to encode an int from my WindowController.
Since the second parameter to encodeValueOfObjCType:at: is an address, I
can not use an ordinary access routine that returns the value, not the
address. So I tried this kludge that seem to work:
In the Document:
[coder encodeValueOfObjCType:@encode(unsigned int) at:[wController addressOfMyInt]];
In the WindowController:
- (void *)addressOfMyInt {
return &myInt;
}
Is there a more elegant solution to this?
According to the declaration of encodeValueOfObjCType:at: the second
param should be (const void*)addr, but if I use this type in my
accessor, the compiler protests on the decoding version which has (void *)data.
- (void)encodeValueOfObjCType:(const char *)type at:(const void *)addr;
- (void)decodeValueOfObjCType:(const char *)type at:(void *)data;
I would be very grateful if anyone could explain to me why the
parameters are declared differently. In Learning Cocoa they are used in
the same way which makes sense to me if I assume that they are both addresses.
Thanks,
Bertil
_______________________________________________
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.