is there a way to run a code only once?Not for each usage.When the user download the app and runs it, the code will run only once and not anymore.
i tried to create a integer with initial 0 and save it to nsuerdefaults.
and made this special code in a if statement check, if its 0 enter the code but if its not 0 don't enter it, and in the if statement i incremented 0 and saved it so it won't ever again enter it.
but it didn't work out
NSInteger temp = [[NSUserDefaults standardUserDefaults] integerForKey:@"forOnce"];
if (temp==0) {
int k=0;
if (NSClassFromString(@"CTTelephonyNetworkInfo"))
{
CTTelephonyNetworkInfo *netInfo =[[CTTelephonyNetworkInfo alloc]init];
CTCarrier *carrier =[netInfo subscriberCellularProvider];
testUser[@"Carrier"]=[carrier carrierName];
//NSLog(@"carrier bu %@",[carrier carrierName]);
}
temp++;
[[NSUserDefaults standardUserDefaults] setInteger:k forKey:@"forOnce"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
the code was something like that