如何增加存储在Objective-C字符串中的数值

Tos*_*eef 2 iphone xcode

如何增加数字字符串值?

如果它最初是"1",我想在每次applicationDidEnterBackground点击时增加它

Mik*_*yev 8

在你的情况下,你为此目的使用字符串很奇怪,但你可以在技术上这样做:

int myInt = [myString intValue];// I assume you need it as an integer.
myString= [NSString stringWithFormat:@"%d",++myInt];
Run Code Online (Sandbox Code Playgroud)