Functional code for the first lottery project in XCode 4.2


#1
  1. File > New > New Project…

  2. [click] Command Line Tool [click] Next

  3. Project Name: Lottery / Type: Foundation

  4. [code]//
    // main.c
    // lottery
    //
    // Created by user on 11/6/11.
    // Copyright © 2011 MyCompanyName. All rights reserved.
    //

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{

@autoreleasepool
{

NSMutableArray *array;
array = [[NSMutableArray alloc] init];
int i;
for( i = 0; i < 10; i++) 
{
    NSNumber *newNumber;
	newNumber = [[NSNumber alloc] initWithInt:(i * 3)];
	[array addObject:newNumber];
}

    
for( i = 0; i < 10; i++)
{
    NSNumber *numberToPrint;
	numberToPrint = [array objectAtIndex:i];
	NSLog(@"The number at index %d is %@", i, numberToPrint);
}
}

return 0;

}

        [/code]