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 。

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

  1. Automake

    Automake是用来根据Makefile.am生成Makefile.in的工具 标准Makefile目标 'make all' Build programs, libraries, document ...

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

    This Chapter outlines the logical steps to writing a good research paper. To achieve supreme excelle ...

  3. Objective C中的ARC的修饰符的使用---- 学习笔记九

    #import <Foundation/Foundation.h> @interface Test : NSObject /** * 默认的就是__strong,这里只是做示范,实际使用时 ...

  4. Objective的字符串拼接 似乎没有Swift方便,但也可以制做一些较为方便的写法

    NSString *str1 = @"字符串1"; NSString *str2 = @"字符串2"; //在同样条件下,Objective的字符串拼接 往往只 ...

  5. [转] 从 C 到 Objective C 入门1

    转自: http://blog.liuhongwei.cn/iphone/objective-c/ 进军iPhone开发,最大的难点之一就是怪异的Objective C语法了.不过,了解之后才发现,原 ...

  6. Objective C运行时(runtime)

    #import <objc/runtime.h> void setBeingRemoved(id __self, SEL _cmd) { NSLog(@"------------ ...

  7. Objective C ARC 使用及原理

    手把手教你ARC ,里面介绍了ARC的一些特性, 还有将非ARC工程转换成ARC工程的方法 ARC 苹果官方文档 下面用我自己的话介绍一下ARC,并将看文档过程中的疑问和答案写下来.下面有些是翻译,但 ...

  8. Modern C++ CHAPTER 2(读书笔记)

    CHAPTER 2 Recipe 2-1. Initializing Variables Recipe 2-2. Initializing Objects with Initializer Lists ...

  9. Objective -C学习笔记之字典

    //字典:(关键字 值) // NSArray *array = [NSArray array];//空数组 // NSDictionary *dictionary = [NSDictionary d ...

随机推荐

  1. [iOS]经常使用正則表達式

    经常使用正則表達式大全!(比如:匹配中文.匹配html) 匹配中文字符的正則表達式: [u4e00-u9fa5]    评注:匹配中文还真是个头疼的事,有了这个表达式就好办了 匹配双字节字符(包含汉字 ...

  2. go内存泄露case

    用go写了一个守护进程程序:用于检測redis的存活状态并将结果写到zookeeper中,部署到redis机器上.对于每一个redis实例会有一个goroutine每隔固定时间去检測其状态,由主gor ...

  3. nhibernate的关系

    用nhibernate,觉得比较难把握的是其中表间的关系. 我用的是Fluently Nhibernate,直接用代码,而不是XML来书写代码与数据表的映射.其中表间关系有3种: 1.Referenc ...

  4. (6)servlet-创建一个servlet类

    1,在项目的src目录下,右键[New]-[Servlet] 2,在弹出窗口中填写信息 Package:所在包名 Name:servlet的类名 Which method stubs would yo ...

  5. Error CREATEing SolrCore 'new_core': Unable to create core [new_core] Caused by: Can't find resource 'solrconfig.xml' in classpath or 'D:\solr\solr-7.2.1\server\solr\new_core'

    \solr-7.2.1\server\solr\configsets\_default  下的conf  复制到:   \solr-7.2.1\server\solr\new_core

  6. JDBC+XML+DOM4J

    利用xml文件封装数据库配置信息xml文件放在src目录下/testjdbc1/src/DBUtil.xml <?xml version="1.0" encoding=&qu ...

  7. buildroot的使用简介【转】

    本文转载自:http://blog.csdn.net/flfihpv259/article/details/51996204 buildroot简介 1 Buildroot at a glance 2 ...

  8. POJ3177 Redundant Paths —— 边双联通分量 + 缩点

    题目链接:http://poj.org/problem?id=3177 Redundant Paths Time Limit: 1000MS   Memory Limit: 65536K Total ...

  9. yum和apt-get 安装方式

    rpm包和deb包是两种Linux系统下最常见的安装包格式,在安装一些软件或服务的时候免不了要和它们打交道.rpm包主要应用在RedHat系列包括 Fedora等发行版的Linux系统上,deb包主要 ...

  10. bzoj 3714 [ PA 2014 ] Kuglarz —— 思路+最小生成树

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3714 因为每个杯子下最多一个小球,所以从奇偶性就可以看出有没有球: 询问一段区间,等于知道一 ...