• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSValue valueWithBytes:objCType:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSValue valueWithBytes:objCType:


  • Subject: Re: NSValue valueWithBytes:objCType:
  • From: Marcel Weiher <email@hidden>
  • Date: Sun, 25 Aug 2013 17:52:09 +0200

On Aug 24, 2013, at 22:09 , Andreas Grosam <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden


References: 
 >NSValue valueWithBytes:objCType: (From: Andreas Grosam <email@hidden>)

  • Prev by Date: Modifying the default -Prefix.pch file
  • Next by Date: Re: Modifying the default -Prefix.pch file
  • Previous by thread: Re: NSValue valueWithBytes:objCType:
  • Next by thread: Modifying the default -Prefix.pch file
  • Index(es):
    • Date
    • Thread