Giter Site home page Giter Site logo

ios-your-first-nslog-001-prework-ios's Introduction

Your First NSLog()

Objectives

  1. Open and navigate an Xcode project file.
  2. Print a message to the debug console during run time.

Review

In the previous reading we surveyed the layout of Xcode's tools. For this first lab, you're going to open and explore the simplest of Xcode projects and write your first line of code—calling a function that prints a string to the debug console. You'll need to navigate to the correct file, edit the code in the editor area, and watch for the printout in the debug console.

Instructions


  1. Open the provided Xcode project inside the lab's directory (your-first-NSLog.xcodeproj). Explore the different areas of Xcode that the reading just discuessed.
  2. In your Project Navigator, look for the file named FISAppDelegate.m (this is the "implementation" file for the FISAppDelegate class). It's within this file that you'll be writing your first line of Objective-C ! Look for this block of code, it's where you'll be adding your first NSLog():
-(BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    // Hey!
    
    // write your code here!  :D
    
    return YES;
}
  1. Type NSLog(@"Hello, World!"); on an empty line within this method—that is, inside the curly braces { ... } and before the return statement. Top Tip: This is a statement. Don't forget the ; ("semi-colon") at the end of your line! It ends your statement.

  2. Now hit ⌘R on your keyboard and your program will run. The iOS Simulator should launch into a black screen. Nothing's wrong! We just haven't given it anything to display in this program so it loads as a black screen.

  3. Look at your debugger output console viewer... your message "Hello, world!" should have printed! Here's a helpful image if you're having trouble:

Note: The spot in the code you were directed to add your NSLog() is the standard override point in the AppDelegate at application launch. We'll explain more of what the means later, but just remember that if you're directed to write code in the AppDelegate, it will likely be in this spot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.