0

I have the following code..

 NSArray *productIdentifiersArray = [packs valueForKey:NSStringFromSelector(@selector(productIdentifier))];
 NSSet *productIdentifiers = [NSSet setWithArray:productIdentifiersArray];

Please see the image below... Why is there an extra element in the first slot of NSSet. I'm not really sure how to debug this but I know I need the NSSet for SKProductsRequest.

enter image description here

1 Answers1

1

Your code is doing exactly what you ask, trimming the duplicate objects from then array. It won't trim empty strings out though, they are entirely valid.

Ideally you wouldn't up the empty strings in the array in the first place, but worst case you can remove the empty string before you use it.

If you make the request with the empty string it will be an little slower and will return the empty string to you as an invalid identifier.

Wain
  • 118,658
  • 15
  • 128
  • 151
  • Thanks, true. My overall actual problem is the `NSArray *products` from SKProductsRequest is coming back with 0 products in the next slice of code. I doubt an empty string would cause this, right? – whoaaallamapajama Apr 02 '15 at 18:36
  • Ah ha!!! I found something at least... `for (NSString *invalidProductId in response.invalidProductIdentifiers){NSLog(@"Invalid product id: %@" , invalidProductId); }` – whoaaallamapajama Apr 02 '15 at 22:27
  • leads to this ...`Invalid product id: com.puteko.colarmix.unlock 2015-04-02 15:25:43.613 Quiver[242:5855] Invalid product id: com.puteko.colarmix.dover 2015-04-02 15:25:44.948 Quiver[242:5855] Invalid product id: com.puteko.colarmix.bdamanfireblast 2015-04-02 15:26:16.568 Quiver[242:5855] Invalid product id: com.puteko.colarmix.packaanz` – whoaaallamapajama Apr 02 '15 at 22:29
  • But that only happens 95% of the time...so now what? – whoaaallamapajama Apr 02 '15 at 22:29
  • Check the status of them in iTunesConnect. It should work or not, not fail only sometimes... – Wain Apr 03 '15 at 08:16