Programming for Non-Programmers: iOS 7
Illustration by Don Barnett

Using pointer variables


From:

Programming for Non-Programmers: iOS 7

with Todd Perkins

Video: Using pointer variables

I mentioned earlier that there are primitive and pointer variables. We've already talked about primitive variables which are numbers and true or false values generally. Pointer values apply to pretty much anything else including text. So, let's look at how pointer works. In our project, under Programming Basics, I'm working in view controller dot m, so single-click on that file to work on the same file that I'm working in. In the view did load function, right under the comment, I'm going to create a string variable.
Expand all | Collapse all
  1. 5m 18s
    1. Welcome
      44s
    2. What you should know before starting this course
      1m 17s
    3. Related courses
      1m 8s
    4. Using the exercise files
      1m 19s
    5. Viewing the finished app
      50s
  2. 10m 24s
    1. Finding and installing Xcode
      35s
    2. Creating an Xcode project
      1m 55s
    3. Understanding the Xcode interface
      3m 54s
    4. Configuring Xcode for app development
      2m 14s
    5. Configuring the iOS Simulator for app development
      1m 46s
  3. 43m 43s
    1. Understanding how programming works
      2m 34s
    2. Understanding variables
      2m 56s
    3. Using primitive variables
      9m 10s
    4. Using pointer variables
      4m 51s
    5. Using instance variables
      5m 19s
    6. Connecting visual objects to variables
      8m 12s
    7. Placing a number variable in a string
      4m 33s
    8. Challenge: Create two variables
      54s
    9. Solution: Create two variables
      5m 14s
  4. 27m 14s
    1. Understanding functions, methods, and selectors
      4m 43s
    2. Using functions, methods, and selectors
      7m 1s
    3. Understanding parameter functions
      2m 10s
    4. Connecting a button to a function
      7m 47s
    5. Challenge: Create a counter app
      43s
    6. Solution: Create a counter app
      4m 50s
  5. 13m 38s
    1. Understanding conditional statements
      2m 35s
    2. Using conditional statements
      5m 21s
    3. Challenge: Build an on/off button app
      39s
    4. Solution: Build an on/off button app
      5m 3s
  6. 44m 59s
    1. Viewing the app's code structure
      2m 11s
    2. Setting up the user interface
      7m 9s
    3. Setting up variables and functions
      5m 8s
    4. Connecting all of the visual elements to code
      2m 59s
    5. Displaying tapped numbers in the calculator
      4m 47s
    6. Controlling when tapped numbers should not appear in the calculator
      3m 27s
    7. Making the Clear button clear all values
      1m 4s
    8. Setting the calculator to add or subtract
      4m 29s
    9. Showing the total when the equals button is tapped
      3m 40s
    10. Formatting a number with commas
      5m 25s
    11. Challenge: Add a multiplication button
      1m 5s
    12. Solution: Add a multiplication button
      3m 35s
  7. 24s
    1. Next steps
      24s

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now
please wait ...
Watch the Online Video Course Programming for Non-Programmers: iOS 7
2h 25m Beginner Apr 10, 2014

Viewers: in countries Watching now:

iOS app development is actually simpler than you might think—even if you're not an experienced programmer. In this course, Todd Perkins bundles the most important concepts in iOS into a quick course, explaining the development process in a visual way that people of any background can understand. No programming experience required! At the end, you'll have a finished app and a basic understanding of Xcode, the toolset for developing iOS apps; building blocks like variables, functions, and conditional statements; and interface design. You can also figure out if an iOS learning path is right for you, without a lengthy time commitment.

If you find you'd like to learn more, see iOS App Development Essential Training, Foundations of Programming: Fundamentals, or any of the other programming courses in our library.

Topics include:
  • Installing Xcode
  • Creating an Xcode project
  • Configuring the iOS Simulator
  • Understanding variables
  • Connecting visual objects to variables
  • Understanding functions, methods, and selectors
  • Connecting a button to a function
  • Using conditional statements
  • Setting up the user interface
  • Connecting code elements to build an app
Subject:
Developer
Software:
iOS
Author:
Todd Perkins

Using pointer variables

I mentioned earlier that there are primitive and pointer variables. We've already talked about primitive variables which are numbers and true or false values generally. Pointer values apply to pretty much anything else including text. So, let's look at how pointer works. In our project, under Programming Basics, I'm working in view controller dot m, so single-click on that file to work on the same file that I'm working in. In the view did load function, right under the comment, I'm going to create a string variable.

A string is a text value. In objective C, a string is created by typing NSString. Now the first three letters are capitalized. As I type NSS, I see that NSString is highlighted in the codentine window. So I'm going to press return on my keyboard to complete that code for me. After that I'm going to type a space, and then I'm going to type an asterisk and the name of my variable, which will be called name. Now I'll set a value to my variable using an equal sign.

Setting a value to an NSString valuable requires quotes and an at symbol. So first we type the at symbol. And then when I type that you'll see that NSString is highlighted in my code. Now if it's not highlighted, you can just type an at symbol and two quotes. Now I'm going to press return on my keyboard to have Xcode auto complete that for me. Now inside of the quotes, we type what is called our string. Again, a string can be a text value that contains letters, numbers and special characters.

So my name is Todd, so I'm going to type Todd in here. And after the final quote, I'm going to type a semi colon. So I've created a variable. The type of variable is NSString. The name of the variable is name. The only thing really different between a pointer, and another type of variable is this asterisk. In other words when you create it, you use an asterisk before the variable name. Then we set the value of the NSString using the at symbol, and we put the value in quotes.

Now let's say we wanted to check to see if we wrote this variable right. Just like we did with our integer variable, we can test the value of our string variable in an NSLog statement. So I'm going to type NSLog, and when it gets highlighted in the code-hinting window, I'm going to press return and then I'm going to type at symbol and some quotes and inside of the quotes my name is and a space. And now we want to put a placeholder for our name variable. For our integer variable the placeholder was percent I.

The placeholder for a NSString variable is percent and instead of I, it's an at symbol. And just like we did with the integer variable after the closed quote, which I have a comma, and then the name of the variable. Which in this case is name. After the closed parentheses, I'm going to add a semicolon and then I'll run the application in IOS simulator. So in the output window, I now see, my name is Todd. I'll click the stop button, close the simulator.

And just like with our integer variable, that placeholder is replaced by the value of the variable when the code runs. Remember, you can overwrite the value of a variable if you change its value on a later line. So if I go to the end of line 21 and go to the next line and type Name, this time we don't need the asterisk, because we've already declared the variable, equals, and then an NSString, which is an at in quotes. And in the quotes, I change my name, say I want to be named Barry.

Then, I just type that. Again, don't forget the semicolon. Run the code and then you'll my name is Barry in the output window. I'll close the simulator. So, primitive variables are the basic numbers' true or false values. Pretty much everything else is a pointer variable, and requires an asterisk when you create it. If you want to log the value of an NSString variable, when you use the NSLog statement, use the percent at symbol placeholder.

There are currently no FAQs about Programming for Non-Programmers: iOS 7.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Programming for Non-Programmers: iOS 7.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.