Programming in Macintosh
Introduction to Xcode
TRAINOR: ALVIE M. BALQUIN, MEng, DCS, CTFL email: [email protected]
Programming in Macintosh Introduction to XCode
Objectives Settings
To know the purpose of XCode tool in Macintosh programming. To create simple projects using Xcode. To learn to Build and Run the Code.
Programming in Macintosh Introduction to Xcode
What is Xcode?
A complicated application to type in, compile, debug and execute your program. Serves as the Integrated Development Environment (IDE). Location: Macintosh HD -> Xcode
Programming in Macintosh Introduction to Xcode
Xcode Window
Programming in Macintosh Introduction to Xcode
Program Creation in Xcode
1. 2. 3. 4. 5. 6. 7. Start the Xcode Application. For new project, select File -> New Project.
For faster use of IDE, better memorize the shortcuts for build, run, etc. Note that you are using a PC keyboard, so check the equivalent of the keys in the Mac Help topics.
Select the type of application, Command Line Utility ->Foundation Tool then click Choose button after. Select the name and location to store your files. Click the file with the .m extension and start to edit the file. Press Command S to save changes. Build and Run the application. If you get compiler error, make changes & save then back to Step 6.
Programming in Macintosh Introduction to Xcode
Basic Program Structure
// First Program Sample #import <Foundation/Foundation.h>
Includes a System File Comment: // or /* */
int main (int argc, const char *argv[ ]) { NSAutoreleasePool *pool = [NSAutoreleasePool alloc] init ]; NSLog (@Hello World!); [pool drain]; return 0; }
Release all objects in the pool marked as autorelease
Keeps track of object references in your program for automatic release later.
Programming in Macintosh Introduction to Xcode
Objectives Checking
To know the purpose of XCode tool in Macintosh programming. To learn to Build and Run the Code. To learn simple debugging using Xcode.
Programming in Macintosh Introduction to Xcode
Workshop 1: Exercise 1
Exercise 1 : Make a program that will ask an integer from the user and determine if the integer is a prime number or not. Sample Outputs: Input an number: 7 7 is a prime number Input a number: 10 10 is not a prime number
Programming in Macintosh Introduction to Xcode
Workshop 1: Exercise 2
Exercise 2 : Determine how many perfect number from 1 to 200. The sum of the factors (except itself) of a perfect number is equal to itself: Sample: 28, ???
Programming in Macintosh Introduction to Xcode
Workshop 1: Exercise 3
Exercise 3: Make a program that will ask an array of n integers. Determine the lowest number in the array and delete it from the array. Sample: How many integers: 4 Input 1: 2 Input 2: 1 Input 3: 6 Input 4: 3
Lowest Number: 1 Array Result: 2, 3, 6
Programming in Macintosh Introduction to XCode
Objectives Checking
To know the purpose of XCode tool in Macintosh programming. To create simple projects using Xcode. To learn to Build and Run the Code.
Programming in Macintosh Introduction to XCode
End of Introduction to XCode -------------------------------------------