1

My app is getting bed reviews because users have to restore their purchase each time they enter the app... That drives me crazy because i don't have that problem on my iPhone. When transaction is made my app calls the following code:

[self.data setObject:[NSNumber numberWithInt:1] forKey:@"fullBought"];
[self.data synchronize];

That's it! Then app checks if([self.data objectForKey:@"fullBought"] != [NSNumber numberWithInt:1).

I tried to remove [self.data synchronize] but i even can't check the result because i don't have that problem!

Help me please to figure out the problem...

serg_ov
  • 563
  • 7
  • 18

1 Answers1

3

The NSUserDefaults doesn't seem to be the issue. You are comparing objects with "!=" operator in this instruction:

if([self.data objectForKey:@"fullBought"] != [NSNumber numberWithInt:1)

You should compare their value instead. With this operator, you are comparing memory addresses. What you should do is:

if([[self.data objectForKey:@"fullBought"] intValue] != 1)
Harold BOULEY
  • 238
  • 1
  • 6
  • Would try it, i thing that's the solution. But why my code works on my device, and for users while they don't kill the app? – serg_ov Aug 24 '14 at 08:17
  • Thanks a lot ;) Forgot that i can't test... Would try to fined some people reporting about the problem and ask them to test for me. – serg_ov Aug 24 '14 at 08:24