I’ve had a problem like this before with adding scores but never solved it so I figured I ask it now and have both problems fixed at the same time. I made an shop where people can buy coins that will be added to their coins they already have. The coins they already have can be loaded by:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *loadcoins = [defaults objectForKey:@"savedcoins"];
[coinsdisplay setText:loadstring];
and I have a button where you can buy 100 coins
-(IBAction)savecoins100:(id)sender {
NSString *savecoins = @"100";
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:savecoins forKey:@"savedcoins"];
[defaults synchronize];
}
What I want is that the new string becomes not @”100″ but 100 + previous coins now this would be loadcoins but I don’t know how to code this correctly can someone help me out?
thanks
Well for starters you should shouldn’t be using strings… Why aren’t you using an integer since you’re counting?
Then where ever you need to display it you can just create a string on the fly.