1 / 33

Instructions 1. Open xCode 2. File -> New Project

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.

romney
Download Presentation

Instructions 1. Open xCode 2. File -> New Project

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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:

  2. 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. Groupsandfilescloseup We 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:

  3. The code here is: for(inti = 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.

  4. 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 = [[NSStringalloc] 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:

  5. 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: %@", [[NSStringalloc] 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.

More Related