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.
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.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.