On Aug 24, 2013, at 22:09 , Andreas Grosam <agro...@onlinehome.de> wrote:

> What's the purpose of NSValue's class method 
> 
> + (NSValue *)valueWithBytes:(const void *)value objCType:(const char *)type; ?
> 
> It seems, NSValue will simply memcpy the content of value, and "somehow" 
> determine the size in bytes from the string given in type. Is that reliable 
> at all? (I have major doubts).

I have to admit I have a hard time fathoming the purpose of NSValue, and 
personally I’ve only every used it “in anger” once.  As far as I can tell, it 
is a backstop when you need to store some random C type in an NSArray and do 
not need semantics, but do want to keep track of the actual type.  I use it 
when my bridge code punts:  I can’t use the value on the “scripting” side of 
the bridge, but I can replay it successfully if it’s needed in another call.

If you need semantics, do not use NSValue, use an actual Objective-C class, 
either by re-creating that struct as an object or wrapping it explicitly.

Cheers,

Marcel

_______________________________________________

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

This email sent to arch...@mail-archive.com

Reply via email to