objective c - Adding Strings to NsMutableSets -


if have 2 string objects both have value "hi", , add them nsmutableset, treated different objects or not? bunch!

beside correct comment of @rmaddy, there fundamental problem it: impossible guarantee no objects equal in set. (it easy guarantee not identical.) imply recheck equaty of objects (expensive), when 1 changes (mostly impossible detect). is, because nsset not copy content objects.

let's have example:

nsmutablestring *first = [@"amin" mutablecopy]; nsmutablestring *second = [@"amin negm" mutablecopy]; nsset *set = [nsset setwithobjects:first, second];  [first appendstring:@" negm"]; 

both objects equal than, none removed. (which one?)


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -