I wrote some code and included the 'random = arc4random() % 50;'. All the code worked but when I finished I noticed that I did not include #import <stdlib.h> but the code still worked. How can that be?
Here is the code
Here is the code
Code:
#import <Foundation/Foundation.h>
@interface randNum : NSObject
{
int random;
}
@property int random;
-(void) print;
-(void) guess;
@end
Code:
#import "randNum.h"
@implementation randNum
@synthesize random;
-(void) print
{
NSLog(@"The random number is %i", random);
}
-(void) guess
{
random = arc4random() % 50;
}
@end
Code:
#import "randNum.h"
int entered;
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
randNum * guesser = [[randNum alloc] init];
guesser.guess;
entered = guesser.random;
guesser.print;
NSLog(@"-----> %i",entered);
guesser.release;
[pool drain];
return 0;
}