• 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: Andreas Grosam <email@hidden>
  • Date: Mon, 26 Aug 2013 09:39:56 +0200

On 25.08.2013, at 19:50, Stephen J. Butler <email@hidden> wrote:

> My guess, and this is only a guess, is that NSValue only uses the type property to make sure two NSValues have the same layout before calling memcmp (or such) on them. We have a lot of evidence that it doesn't do a deep inspection of the type in order to give a more accurate comparison.
>
> Can you not bzero() the structs before writing to them and placing them in NSValues? That would solve your problem.

That's not a general solution. Consider:


// Some Library:

struct s_t { … };
s_t foo();
s_t bar();


// Apple's library:
// macro:
#define StructsAreEqual(a, b) \
    … // uses NSValue's method isEqualToValue:

// My code:
assert( StructsAreEqual(foo(), bar()) );


My point is, the macro "StructsAreEqual" is not reliable.



Andreas




_______________________________________________

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


  • Follow-Ups:
    • Re: NSValue valueWithBytes:objCType:
      • From: Kyle Sluder <email@hidden>
References: 
 >NSValue valueWithBytes:objCType: (From: Andreas Grosam <email@hidden>)
 >Re: NSValue valueWithBytes:objCType: (From: Jean-Daniel Dupas <email@hidden>)
 >Re: NSValue valueWithBytes:objCType: (From: Andreas Grosam <email@hidden>)
 >Re: NSValue valueWithBytes:objCType: (From: "Stephen J. Butler" <email@hidden>)

  • Prev by Date: Re: "Introducing ioscomponents.com"
  • Next by Date: Re: Retina / non retina : Drawing icons
  • Previous by thread: Re: NSValue valueWithBytes:objCType:
  • Next by thread: Re: NSValue valueWithBytes:objCType:
  • Index(es):
    • Date
    • Thread