Skip to content

learn-co-students/wwdc-badges-001

Repository files navigation

WWDC Badges

Objectives

  1. Create an array containing string objects.
  2. Iterate over an array with a for loop.
  3. Access an array's elements with subscripting syntax.
  4. Use an array's elements to print a dynamically interpolated string to the console.

Introduction

You're helping out at Apple's Worldwide Developers Conference this year. Your task is to print badges for each of the eight keynote speakers. Each speaker's badge needs to say, "Hello, my name is <#name#>." with the <#name#> field filled with that speaker's name.

This is not a code-along. You will need to solve this lab yourself by incorporating various elements from previous lessons to get the correct printout in your debug console.

Instructions

Fork and clone this lab. Open the wwdc-badges.xcodeproj file and navigate to the FISAppDelegate.m implementation file. Write your code in the application:didFinishLaunchingWithOptions: method.

  1. Create an NSArray object named conferenceSpeakers to store the list of speaker names as strings:

That's quite a lineup!

  1. Iterate over the conferenceSpeakers array using a for loop. (Remember, arrays begin at index 0!) Use string interpolation with an NSLog()inside the loop to print "Hello, my name is <#name#>." for each speaker's name in the array.

  2. Run (+R) the application. You should see the following lines print out in the debug console.

Hello, my name is Anita Borg.
Hello, my name is Alan Kay.
Hello, my name is Ada Lovelace.
Hello, my name is Aaron Swartz.
Hello, my name is Alan Turing.
Hello, my name is Michael Faraday.
Hello, my name is Grace Hopper.
Hello, my name is Charles Babbage.

It's too bad that Inigo Montoya was already booked.

Advanced

Instead of using a single array for names, split the names into two separate arrays for first name and last name. Alter your NSLog() to take two format arguments, one from each array: Hello, my name is <#firstName#> <#lastName#>.. You should get an equivalent result to the one shown above.

View this lesson on Learn.co

View WWDC Badges on Learn.co and start learning to code for free.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published