+ All Categories
Home > Documents > Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type...

Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type...

Date post: 19-Dec-2015
Category:
View: 218 times
Download: 2 times
Share this document with a friend
33
Transcript
Page 1: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 2: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 3: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 4: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 5: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 6: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 7: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 8: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 9: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 10: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 11: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 12: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 13: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.

Instructions

1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really doesn’t matter for this exercise since we will only be programming a for loop to print and not creating any User Interface. 4. Call the project iCodeBlogCounter 5. After saving the project you will be confronted with a screen looking something like this.

xcodefirstscreen:

Page 14: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 15: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.

If you look in the top left hand corner you will see a folder called Classes. If you click the little black triangle to the left of the folder you will see what is included in the classes folder. In there you should see a class called iCodeBlogCounterAppDelegate.m. This is the file we will be working with. Click on it and you will see its contents appear in the editor window.

GroupsandfilescloseupWe will be working with the – ((void)applicationDidFinishLaunching:(UIApplication *)application method. This method is called when the application finished launching. We will be entering some very simple code that will simple count from 0 to 99 and print the numbers in the terminal window. Here is what the method should look like:

Page 16: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.

The code here is:

for(int i = 0; i < 100; i++){ NSLog(@"The current number is: %d", i);}

That is all we need to do for this app. Now time to see it in action. To bring up the terminal window hit SHIFT + APPLE + R, this should bring up a blank window with maybe a line of text in it. Now click Build and Run or hit Apple + R. The terminal windows should say “The current number is 0″ all the way to “The current is 99″. Here is a screenshot of my window.

Page 17: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 18: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 19: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 20: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 21: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 22: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 23: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 24: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 25: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 26: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 27: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 28: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.

1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really doesn’t matter for this exercise since we will only be programming a for loop to print and not creating any User Interface. 4. Call the project iCodeBlogGetURLText 5. Once the project is open go into the iCodeBlogURLTextAppDelegate.m file. 6. Add this code to the - (void)applicationDidFinishLaunching:(UIApplication *)application method

NSString *myURLString = @"http://losectrl-gaincommand.com/iCodeBlogHelper/Tutorial2/iCodeBlog.txt"; NSURL *myURL = [NSURL URLWithString:myURLString]; NSString *myString = [[NSString alloc] stringWithContentsofURL:myURL];

NSLog(@"The string from the internet is: %@", myString);

7. If you bring up the terminal window and Build and Run the App. You should see:

Page 29: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 30: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 31: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.

Instructions

1. Go back to the code we just wrote. 2. Erase the 4 lines of code we wrote and replace it with this line:

NSLog(@"The string from the internet is: %@", [[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://losectrl-gaincommand.com/iCodeBlogHelper/Tutorial2/iCodeBlog.txt"]]);

3. Running the application again should have the same output. 4. Here is a a breakdown of out new line of code.

Page 32: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.
Page 33: Instructions 1. Open xCode 2. File -> New Project 3. Start a new View based iPhone Project. The type of project you create really.

Recommended