Okay, so I'm officially confused.

I have an object with isEqual set up to help me limit the number of "unique" 
objects I can put in a Dictionary. Basically, the object has a few properties 
which account for "equality", and some properties that don't matter. For 
example, propA and propB are used in isEqual, but propC isn't. The point is 
that I can create a set with objects where only propA and propB are different, 
and propC just is irrelevant. Maybe that seems weird, but it's what I need. 

But what I don't get is how hash plays into all this. I've always read that I 
have to override hash when I override isEqual, but I don't exactly understand 
what that means or does. What I've done is to make a hash that is equal when 
two objects have the same values for propA and propB (ignoring propC). That's 
how I interpreted the few threads I've read about overriding hash...

But what I need to do in my code, right now, is to copy an object, then alter 
some properties of the copy, but not the original -- a typical reason for 
wanting a copy. But I'm seeing that the copy has the same hash and appears to 
be the same object, since changing properties of the copy changes the original. 
So does the system see the matching hashes as identical objects, not just the 
collection classes? Do I have to manually implement some sort of deepCopy 
method? Or, can I just change hash, so that the copy is a different instance, 
without losing the functionality I need for collections? I don't understand why 
I'd need to make a deepCopy, since that's what copy is for...

Any help greatly appreciated.

J.


------------------------------------------------------
James B. Maxwell
Composer/Researcher/PhD Candidate






_______________________________________________

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