You can't really get a computer to generate numbers that are truly random and unpredictable, but we can employ a so-called pseudo-random generator to spit out numbers that at least appear that way.
arc4random()
targetValue = 1 + (arc4random() % 100);
The function arc4random() delivers an arbitrary integer between 0 and about 4 billion.
If we want to limit the random number to be between 1 and 100, just as the codes above.