title: NSMutableSet Set Minus Set Not Working
body: <p>I must be missing something fundamental - hopefully someone can point it out to me.</p>
  
  <p>I have two NSSets. Set A contains 40 NSNumber values and set B contains 20 NSNumber values. Set A contains all of set B's 20 values plus 20 other values not shared by the sets. </p>
  
  <p>What I'd like is to do: NSSet *newSet = Set A - Set B, where the new set only contains the 20 values from set A not contained in set B. Although I am using 'minusSet', my new set always contains all 40 of the original values. I have logged the contents of each set A and B to make sure that they contain the contents that I described above.</p>
  
  <p>Here is my code:</p>
  
  <p>1) Create set A (contains 40 NSNumbers)</p>
  
  <pre><code>NSMutableSet *fetchedThreadIds = [NSMutableSet setWithArray:[threadedJsonMessages valueForKey:@"tid"]];
  </code></pre>
  
  <p>2) Create set B (contains 20 NSNumbers which are also in set A)</p>
  
  <pre><code>NSSet *savedThreads = threadIdsForSavedThreads([fetchedThreadIds allObjects]);
  </code></pre>
  
  <p>3) Attempt to subtract set B from set A: </p>
  
  <pre><code>[fetchedThreadIds minusSet:savedThreads];
  </code></pre>
  
  <p>4) Add all remaining objects to new array:</p>
  
  <pre><code>threadIdsForMessageFetch = [fetchedThreadIds allObjects];
  </code></pre>
  
  <p>However, threadIdsForMessageFetch contains 40 objects rather than 20. When I print each set I get:</p>
  
  <p>Set A</p>
  
  <pre><code>{(
  2540000000136987400,
  2540000000141777055,
  2540000000144609986,
  2540000000125243232,
  2540000000144610000,
  2320000003021796109,
  2540000000144375484,
  2540000000136185765,
  2540000000135311778,
  2540000000135311816,
  2540000000124128112,
  2540000000125012438,
  2480000001401011569,
  2540000000144610015,
  2540000000135311744,
  2540000000139755359,
  2540000000135311848,
  2540000000143846308,
  2540000000145732667,
  2540000000143985955,
  2540000000136185740,
  2540000000135756434,
  2540000000134373148,
  2540000000140816249,
  2540000000130860748,
  2540000000127140093,
  2540000000143526120,
  2540000000102176392,
  2540000000144609962,
  2540000000128826163,
  2540000000136185694,
  2540000000133208691,
  2540000000144555891,
  2540000000138091838,
  2540000000130179358,
  2540000000126098342,
  2540000000145162237,
  2540000000131688927,
  2540000000136185715,
  2540000000143526101
  )}
  </code></pre>
  
  <p>Set B</p>
  
  <pre><code>{(
  2540000000136987400,
  2540000000138091838,
  2540000000143985955,
  2540000000144555891,
  2540000000140816249,
  2540000000145732667,
  2540000000144609986,
  2540000000144610000,
  2540000000144609962,
  2540000000144610015,
  2540000000141777055,
  2540000000143526101,
  2540000000143526120,
  2480000001401011569,
  2540000000136185694,
  2540000000145162237,
  2540000000143846308,
  2320000003021796109,
  2540000000144375484,
  2540000000139755359
  )}
  </code></pre>
  
  <p>New Array:</p>
  
  <pre><code>&lt;__NSArrayI 0xc4b8e40&gt;(
  2540000000136987400,
  2540000000141777055,
  2540000000144609986,
  2540000000125243232,
  2540000000144610000,
  2320000003021796109,
  2540000000144375484,
  2540000000136185765,
  2540000000135311778,
  2540000000135311816,
  2540000000124128112,
  2540000000125012438,
  2480000001401011569,
  2540000000144610015,
  2540000000135311744,
  2540000000139755359,
  2540000000135311848,
  2540000000143846308,
  2540000000145732667,
  2540000000143985955,
  2540000000136185740,
  2540000000135756434,
  2540000000134373148,
  2540000000140816249,
  2540000000130860748,
  2540000000127140093,
  2540000000143526120,
  2540000000102176392,
  2540000000144609962,
  2540000000128826163,
  2540000000136185694,
  2540000000133208691,
  2540000000144555891,
  2540000000138091838,
  2540000000130179358,
  2540000000126098342,
  2540000000145162237,
  2540000000131688927,
  2540000000136185715,
  2540000000143526101
  )
  </code></pre>
  
  <p>The counts of A and B before the minus set call are as follows:</p>
  
  <pre><code>2014-05-14 22:37:00.900 App[35877:60b] fetchedThreadIdsCount = 40
  2014-05-14 22:37:00.900 App[35877:60b] savedThreadsCount = 20
  </code></pre>