Re: Modifying Set via NSArrayController breaks Set in weird way
Re: Modifying Set via NSArrayController breaks Set in weird way
- Subject: Re: Modifying Set via NSArrayController breaks Set in weird way
- From: Quincey Morris <email@hidden>
- Date: Fri, 08 Jan 2016 11:24:20 -0800
- Feedback-id: 167118m:167118agrif8a:167118sAWgWymCZt:SMTPCORP
On Jan 8, 2016, at 09:59 , Etan Kissling <email@hidden> wrote:
>
> As the comments in the sample project describe in the introductory comments,
> modifying the code to force an NSSet does not solve the problem.
a. I believe your debugger display problems are just that — problems in the debugger, not necessarily anything to do with your code (though certainly getting in the way). I’ve seen other cases where the debugger generates huge output (many megabytes of text) and ties Xcode up for 20 minutes or more while doing it.
b. With your original Set<Foo> code, the set does indeed change from a Swift internal implementation to a _XXX_NSSet implementation after you add an entry via the array controller, though this is probably irrelevant.
c. With your Set<Foo> code, you should probably be using ==, not isEqual, even though the Foos are NSObjects.
d. For NSObject equality, the hash getter method is called ‘hash’, not ‘hashValue’.
I don’t know offhand if Swift tries to bridge between ‘hash’ and ‘hashValue’ under any circumstances. (It seems like it must, otherwise I don’t see how Set and Set<> could bridge properly, but I admit I haven’t taken the time to try to think this through.) However, I suspect that your immediate problems are cause by the lack of a ‘hash’ method. Certainly, when I changed the Set<Foo> variable to NSMutableSet, your hashValue method wasn’t ever called.
_______________________________________________
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