On 8 Aug 2008, at 09:04, Sean McBride wrote:

Gerriet M. Denkmann ([EMAIL PROTECTED]) on 2008-8-8 9:49 PM said:

        some_type a;
        NSValue *data = [ NSValue value: &a withObjCType: @encode
(some_type) ];  
followed by:
        some_type b;
        [ data getValue: &b ];
is unsafe, dangerous and strictly to be avoided - especially if the
definiton of "some_type" is buried in some frameworks.

Instead one must use:
        some_type *bPointer = [ data bytes ];
The only problem: NSValue has no method "bytes".

Note that the docs say that value:withObjCType: and objCType "may be
deprecated in a future release".  Also, I suspect objCType would be
problematic in GC apps (see archive discussion of NSData's btyes method).

On the other hand NSData will definitely have problems if it is sent via Distributed Object to another application with another endian-ness. But this not something which I will do with this app. And I am also not sure whether NSValue will do the right thing with DO.


What is your ultimate goal?  Could you use NSData instead of NSValue?
Just to transport data. In the case which caused me so much trouble 144 bytes of FSCatalogInfo.
But, now that you mention it, I could use NSData instead.
And probably will, as I am tired of fighting with NSValue.
Thanks for this suggestion. I was kind of hooked on NSValue for - as I see now - no good reason.


Kind regards,

Gerriet.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to