Frage

I'm currently using two JSON web-services to fill two separate NSMutableArrays asynchronously.

Local Stock & Supplier stock

The first web-service retrieves local stock, the other one retrieves supplier stock. So after the two arrays get filled, I run a -(void)compareArrays function after dispatch_group_wait(group, DISPATCH_TIME_FOREVER);

Custom object

I use a custom object to store the data from the webservices. Each object represents one product.

Different keys per webservice (same (type of) value)

Since both webservices return differently named key-value pairs (since one returns its key in Dutch, the other in English) I've got two parsing functions for the object. Basically the [dictionary objectForKey:@"property"] is different when parsing the different Web-services, but the properties it's setting are the same.

Update local stock information with supplier stock information

The supplier-webservice also returns products that are being returned by the local stock webservice. Certain properties on the local product have to be updated by the supplier-webservice, and I'm trying to make it work.

Now this works for a lot of products, but some products somehow don't set off the if-loop. I've checked the JSON-result as well as putting both the local and the supplier version of the product in NSLog: their hashes and externalItemId's were the same.

This object somehow doesn't get through the if loop, even though just after creation, the externalItemId is being set to the value of the "artikelsysteemnummer", which is the supplier-webservice's key for the externalItemId. Their hashes are identical as well.

Does anybody have an idea where it might go wrong? Because I see this product being skipped by the MergeArrays-function, and the grossPrice remains 0 instead of 13100.

Thanks in advance!

Update

I checked my code again, and in the WebService-code there was this little debug code stuck in there that said if the supplier-stock was 0, don't add the product to the array. Though I forgot to remove it (as some supplier stock might return 0, but we would have it in local stock, hence the product didn't update).

Thanks everybody and have happy holidays!

War es hilfreich?

Lösung

Sorry guys! I just checked my code, and there was this stupid debug if-loop I forgot to remove in the webservice-code that prevented several products from being added to the array. Thanks for the help though!

(I've updated the main post to reflect this)

Andere Tipps

Please change the isEqual method implementation method and try. May be the problem is here. from if (![externalItemId isEqual:[otherProduct externalItemId]]) return NO;

To if (![externalItemId isEqualToString:[otherProduct externalItemId]]) return NO;

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top