Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to avoid the duplicate dictionary objects in NSMutableArray
    primarykey
    data
    text
    <p>Hi in one of my application,I have an array which contains a group of <code>NSMutableDictionary</code> objects. The dictionary object have three key-value pairs as like below</p> <ol> <li>company</li> <li>product</li> <li>quantity</li> </ol> <p>And array having many number of objects. Here now by using different add buttons I am adding these dictionary objects to the array. Even while adding objects to array i am checking whether any duplicate objects are available or not using <code>NSNotFound</code> method. As such below</p> <pre><code>if([Array indexOfObject:dicObject] == NSNotFound) { [Array addObject:dicObject]; } </code></pre> <p>Here it is working fine in few cases, But it's not working in other cases.I will explain with one example :</p> <ol> <li><p>For example i have one dicobject in array with following key value pairs</p> <p><code>company:XYZ Product:ABC Quantity:2</code></p></li> </ol> <p>Now for example I want to add one more dic object with the same above key value pairs. That time obviously it won't add because already same product is available in array.</p> <p>This is valid condition.</p> <p>Exceptional Case: For example I want to add one more product with following values</p> <pre><code>Company:XYZ Product:ABC Quantity:6 </code></pre> <p>At this case this product is adding into the array without any error. But my concern is i don't want to add this into the array again only the quantity have to update, because company and product name both are same so. So can you please show me the way to handle this scenario.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload