• Complain

Campbell - Objective-C Quick Syntax Reference

Here you can read online Campbell - Objective-C Quick Syntax Reference full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. City: Berkeley;Calif, year: 2014, publisher: Apress, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Campbell Objective-C Quick Syntax Reference
  • Book:
    Objective-C Quick Syntax Reference
  • Author:
  • Publisher:
    Apress
  • Genre:
  • Year:
    2014
  • City:
    Berkeley;Calif
  • Rating:
    3 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 60
    • 1
    • 2
    • 3
    • 4
    • 5

Objective-C Quick Syntax Reference: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Objective-C Quick Syntax Reference" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Objective-C Quick Syntax Reference — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Objective-C Quick Syntax Reference" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Matthew Campbell Objective-C Quick Syntax Reference 10.1007/978-1-4302-6488-0_1
Matthew Campbell 2013
1. Hello World
Matthew Campbell 1
(1)
CA, US
Abstract
Objective-C is a programming language that extends the C programming language to include object-oriented programming capabilities. This means that most classic C programming procedures are used in Objective-C programs. For the purposes of this book, you will need to have an idea of how C programming works.
Xcode
Objective-C is a programming language that extends the C programming language to include object-oriented programming capabilities. This means that most classic C programming procedures are used in Objective-C programs. For the purposes of this book, you will need to have an idea of how C programming works.
Before you write any Objective-C code, you will need to have the proper tool for the job. For Objective-C, this tool is Xcode. Xcode will be your primary code editor and integrated development environment (IDE).
Note
Xcode requires a Mac. You cannot install Xcode on a Windows-or Linux-based computer.
To install Xcode, go to the Mac App Store by selecting your Macs menu bar and then choosing App Store . Use the App Store search feature to locate Xcode by typing the word Xcode into the textbox next to the hourglass. Press return to search for Xcode. You will be presented with a list of apps, and Xcode should be the first app in the list. Install Xcode by clicking the button with the word free next to the Xcode icon. See Figure for the screen that you should see once you searched for Xcode in the App Store.
Figure 1-1 Downloading Xcode from the App Store Creating a New Project - photo 1
Figure 1-1.
Downloading Xcode from the App Store
Creating a New Project
Open Xcode by going to your Applications folder and clicking the Xcode app. You will be presented with a welcome screen that includes text that reads Create a new Xcode project (see Figure ). Click the text Create a new Xcode project to get started.
Figure 1-2 Xcode welcome screen The next screen that appears will list - photo 2
Figure 1-2.
Xcode welcome screen
The next screen that appears will list options for creating apps both for iOS and Mac. In this book, you will be using a Mac Command Line Tool app, so set up this by choosing OSX Application Command Line Tool .
When the next screen appears, just give your new project a name, choose the type Foundation, leave the other settings as they are, and then click Next .
Now choose a folder to save the Xcode project on your Mac. Once you do this, an Xcode screen will appear. The Xcode screen will include a list of files on the left and a code editor in the center (see Figure ).
Figure 1-3 Code editor and project navigator Hello World Writing Hello - photo 3
Figure 1-3.
Code editor and project navigator
Hello World
Writing Hello World in code is what we do when want to make sure that we have set up a code project correctly. Xcode makes this really easy to do because new Command Line Tool projects come with Hello World already coded.
All you need to do is use the Project Navigator , the widget on the left-hand area of your Xcode screen, to locate the file named main.m . Click main.m to open the file in the code editor (Figure ).
Figure 1-4 Editing mainm When you do this you will see code that looks a - photo 4
Figure 1-4.
Editing main.m
When you do this you will see code that looks a bit like this:
#import
int main(int argc, const char * argv[]){
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
}
return 0;
}
Much of the code above sets up the application, starting with the #import statement. This statement imports the code that you need, called Foundation , for your Objective-C program to work.
The next part of the code above is the function named main , which contains all the program code and returns the integer when the program is complete.
Inside the main function you will see an Objective-C auto release pool. Auto release pools are required to support the memory management system used with Objective-C. The auto release pool is declared with the @autoreleasepool keyword.
In the middle of all this code, you can see the Hello World code, which looks like this:
NSLog(@"Hello, World!");
The first piece of this is the function NSLog . NSLog is used to write messages to the console log. Xcodes console log is located at the bottom of the Xcode screen (Figure ) and presents error messages along with messages that you send using NSLog .
Figure 1-5 Hello World output in console screen Note By default the - photo 5
Figure 1-5.
Hello World output in console screen
Note
By default the console log is hidden along with the debugger at the bottom of the screen. To see these two components you must unhide the bottom screen by clicking the Hide or Show Debug Area toggle located in the top right-hand part of the Xcode screen. This button is located in the middle of a set of three buttons.
The string Hello World is enclosed with quotes ( "") and the Objective-C escape character @ . The @ character is used in Objective-C to let the compiler know that certain keywords or code have special Objective-C properties. When @ is before a string in double quotes, as in @"Hello, World!" , it means that the string is an Objective-C NSString object.
Code Comments
There is one more line of code that Xcode helpfully inserted into this project for you. This line of code is a good example of a code comment and begins with these two special characters: //. Here is what the code comment looks like:
// insert code here...
Code comments are used to help document your code by giving you a way to insert text into the program that will not be compiled into a working program.
Build and Run
To test the code, click the Run button in the top upper left area of the Xcode screen. See Figure to see which button to push.
Figure 1-6 Building and running the Hello World code When you click the Run - photo 6
Figure 1-6.
Building and running the Hello World code
When you click the Run button, Xcode will compile the code in the Xcode project and then run the program. The program you have been working on will print out the words Hello World. You can see the output circled in Figure .
Where to Get More Information
This book is a quick reference for Objective-C, and I have focused on the code and patterns that I judge will be most useful for most people. However, this means that I cant include everything in this book.
The best place to get complete information on Objective-C and the Mac and iOS applications that you can create with Objective-C is the Apple Developer web site. You can get to the Apple Developer web site by using a web browser to navigate to http://developer.apple.com/resources .
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Objective-C Quick Syntax Reference»

Look at similar books to Objective-C Quick Syntax Reference. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Objective-C Quick Syntax Reference»

Discussion, reviews of the book Objective-C Quick Syntax Reference and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.