Re: NSValue valueWithBytes:objCType:
Re: NSValue valueWithBytes:objCType:
- Subject: Re: NSValue valueWithBytes:objCType:
- From: "Stephen J. Butler" <email@hidden>
- Date: Sun, 25 Aug 2013 12:50:53 -0500
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.
On Sun, Aug 25, 2013 at 12:34 PM, Andreas Grosam <email@hidden>wrote:
>
> On 24.08.2013, at 23:01, Jean-Daniel Dupas <email@hidden> wrote:
>
> >
> > Le 24 août 2013 à 22:09, Andreas Grosam <email@hidden> a écrit
> :
> >
> >
> > That's not a problem specifics to NSValue.
>
>
> I disagree. Please read the documentation of NSValue:
>
> valueWithBytes:objCType:
> Creates and returns an NSValue object that contains a given value, which
> is interpreted as being of a given Objective-C type.
>
>
> isEqualToValue:
> Returns a Boolean value that indicates whether the receiver and another
> value are equal.
>
>
> The fact is, the result of isEqualToValue: is more often undefined,
> implementation defined or completely random when applied to structs.
>
>
> > You should know what you do when manipulating structs.
>
> I think, I do - otherwise, I wouldn't come up with this problem. The
> problem is, that in some library which we cannot mention here, two encoded
> structs wrapped into NSValues together with method isEqualToValue: will be
> used as a means to compare structs. IMO, this's not a reliable approach.
>
>
> 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
>
_______________________________________________
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