Objective - c Chapter 1 -2 Hello world

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 ->New Project.

1.3.在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 ?R.

Open the Xcode console window (by selecting View Debug Area Activate Console or pressing ??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 included only once, no matter how many times the #import directive is actually seen for that file.

#import 保证头文件只能被包含一次,不论#import 引入多少次这个文件。

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.

一个框架包含了头文件,库,图片,声音甚至更多到一个单元中。

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 across 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 很聪明: 它使用预编译头文件,压缩

1.4.3

NSLog and @"Strings "

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

The NS Prefix: A Prescription Against Name Collisions

NS前缀: 预防名字冲突。

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.

历史原因,原来NestStep的缩写NS。所以一直这么简写了。

1.4.4

NSString: Where it‘s @

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

一个在双引号前加at 符号@ 意思是说被引用的字符串应该视为cocoa NSSting 元素。

an NSString is a sequence of characters in Cocoa.

一个NSstring是一些列在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 .

设置xcode使得对待警告如同错误。

1.5 Are you the  boolean type ?

Many languages 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 也有Boolean 类型。

类型是Bool 。

时间: 2024-12-20 01:06:51

Objective - c Chapter 1 -2 Hello world的相关文章

CCJ PRML Study Note - Chapter 1.5 : Decision Theory

Chapter 1.5 : Decision Theory Chapter 1.5 : Decision Theory Christopher M. Bishop, PRML, Chapter 1 Introdcution 1. PRML所需要的三论: Probability theory: provides us with a consistent mathematical framework for quantifying and manipulating uncertainty. Deci

CCJ PRML Study Note - Chapter 1.3-1.4 : Model Selection &amp; the Curse of Dimensionality

Chapter 1.3-1.4 : Model Selection & the Curse of Dimensionality Chapter 1.3-1.4 : Model Selection & the Curse of Dimensionality Christopher M. Bishop, PRML, Chapter 1 Introdcution 1. Model Selection In our example of polynomial curve fitting using

CHAPTER 1 Introduction to database (第一章 数据库简介)

Chaper  Objectives  (章节目标) In this chapter you will learn:   (在这一章节中,你将学习) 1. Some common uses of database systems.   (数据库系统的一些普通扩法) 2.The characteristics of file-based systems. (基于文件系统的一些特点.) 3. The problems with the file-based systems.  (基于文件系统拥有的一

如何写出优秀的研究论文 Chapter 1. How to Write an A+ Research Paper

This Chapter outlines the logical steps to writing a good research paper. To achieve supreme excellence or perfection in anything you do, you need more than just the knowledge. Like the Olympic athlete aiming for the gold medal, you must have a posit

Chapter 2 Conceptual design

A cylindrical scanning setup with an optical distance probe is non-contact, universal and fast. With a probe with 5 mm range, circular tracks on freeform surfaces can be measured rapidly with minimized system dynamics. By applying a metrology frame r

Chapter 3 Motion system

The motion system positions the probe relative to the product in 4 degrees of freedom. The product is mounted on an air bearing spindle (), and the probe is positioned over it in radial (r), vertical (z) and inclination (ψ) direction by the R-stage,

《Cloud Native Infrastructure》CHAPTER 1(2)

Cloud Native Infrastructure "Cloud Native"是一个被市场过度解读的术语,但是它对于工程与管理来说仍然具有意义,对于我们,这是公有云提供商的技术演变史. "Cloud native" is a loaded term. As much as it has been hijacked by marketing departments, it still can be meaningful for engineering and m

ANSI Common Lisp Chapter 2

Chapter 2 总结 (Summary) Lisp 是一种交互式语言.如果你在顶层输入一个表达式, Lisp 会显示它的值. Lisp 程序由表达式组成.表达式可以是原子,或一个由操作符跟着零个或多个实参的列表.前序表示法代表操作符可以有任意数量的实参. Common Lisp 函数调用的求值规则: 依序对实参从左至右求值,接着把它们的值传入由操作符表示的函数. quote 操作符有自己的求值规则,它完封不动地返回实参. 除了一般的数据类型, Lisp 还有符号跟列表.由于 Lisp 程序是

Chapter 5 MySQL Server Administration_1

Chapter 5 MySQL Server Administration Table of Contents 5.1 The MySQL Server 5.1.1 Configuring the Server 5.1.2 Server Configuration Defaults 5.1.3 Server Option and Variable Reference 5.1.4 Server Command Options 5.1.5 Server System Variables 5.1.6