Objective, objectivec

Source: Internet
Author: User
Tags at sign

Objective, objectivec

 

Objective-c Chapter 1 Hello world

1.1

1.2.On the Welcome screen, click "Create a new Xcode project" (see Figure 2-1), or just choose
File-> New Project.

 

1. 3. Write the following code in main

 

#import <Foundation/Foundation.h>int main(int argc, const char * argv[]) {    @autoreleasepool {        // insert code here...        NSLog(@"Hello, World!");    }    return 0;}

 

Build and run the program by clicking the Run button or pressing procedure R.

Open the Xcode console window (by selecting View Debug Area Activate Console or pressing publish objective C), which displays your program's output,

 

 

 

Now Let's pull it apart and see how it works.

 

1.4.1

# Import

# Import <Foundation/Foundation. h>

# Import guarantees that a header file will be encoded only once, no matter how many times the # import directive is actually seen for that file.

# Import ensures that the header file can only be contained once, no matter how many times # import introduces the file.

 

1.4.2

Introducing Frameworks

A framework is a collection of parts-header files, libraries, images, sounds, and more-collected together into a single unit.

A framework contains header files, libraries, images, sounds, and even more.

The header files for the Foundation framework take up nearly a megabyte of disk storage and contain more than 14,000 lines of code, spread upload SS over a hundred files. when you include the master header file with # import <Foundation/Foundation. h>, you get that whole vast collection.

 

Xcode is smart: it speeds up the task by using precompiled headers, a compressed and digested form of the header that's loaded quickly when you # import it.

Xcode is clever: it uses pre-compiled header files to compress

1.4.3

NSLog and @ "Strings"

NSLog (@ "Hello, Objective-C! ");

 

The NS Prefix: A presponagainst Name Collisions

NS Prefix: prevents name conflicts.

Rather than break compatibility with code already written for NextSTEP, Apple just continued to use the "NS" prefix. It's a historical curiosity now, like your appendix.

Historical reasons: the abbreviation of NestStep NS. So it is always so short.

1.4.4

NSString: Where it's @

 

A string in double quotes preceded by an at sign means that the quoted string shoshould be treated as a Cocoa NSString element.

Adding the at symbol @ before double quotation marks means that the referenced string should be regarded as a cocoa NSSting element.

An NSString is a sequence of characters in Cocoa.

An NSstring is a character of some columns in cocoa.

NSString elements have a huge number of features packed into them and are used by Cocoa any time a string is needed. Here are just a few of the things an NSString can do:

Tell you its length
Compare itself to another string
Convert itself to an integer or floating-point value

 

You can tell Xcode to always treat warnings as errors.

Setting xcode makes warning like an error.

 

 

 

1.5 Are you the boolean type?

Invalid versions ages have a Boolean type, which is, of course, a fancy term for variables that store true and false values. Objective-C is no exception.

Oc also has the Boolean type.

The type is Bool.

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.