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 。
Objective - c Chapter 1 -2 Hello world的更多相关文章
- Automake
Automake是用来根据Makefile.am生成Makefile.in的工具 标准Makefile目标 'make all' Build programs, libraries, document ...
- 如何写出优秀的研究论文 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 ...
- Objective C中的ARC的修饰符的使用---- 学习笔记九
#import <Foundation/Foundation.h> @interface Test : NSObject /** * 默认的就是__strong,这里只是做示范,实际使用时 ...
- Objective的字符串拼接 似乎没有Swift方便,但也可以制做一些较为方便的写法
NSString *str1 = @"字符串1"; NSString *str2 = @"字符串2"; //在同样条件下,Objective的字符串拼接 往往只 ...
- [转] 从 C 到 Objective C 入门1
转自: http://blog.liuhongwei.cn/iphone/objective-c/ 进军iPhone开发,最大的难点之一就是怪异的Objective C语法了.不过,了解之后才发现,原 ...
- Objective C运行时(runtime)
#import <objc/runtime.h> void setBeingRemoved(id __self, SEL _cmd) { NSLog(@"------------ ...
- Objective C ARC 使用及原理
手把手教你ARC ,里面介绍了ARC的一些特性, 还有将非ARC工程转换成ARC工程的方法 ARC 苹果官方文档 下面用我自己的话介绍一下ARC,并将看文档过程中的疑问和答案写下来.下面有些是翻译,但 ...
- Modern C++ CHAPTER 2(读书笔记)
CHAPTER 2 Recipe 2-1. Initializing Variables Recipe 2-2. Initializing Objects with Initializer Lists ...
- Objective -C学习笔记之字典
//字典:(关键字 值) // NSArray *array = [NSArray array];//空数组 // NSDictionary *dictionary = [NSDictionary d ...
随机推荐
- Eclipse 变量点击高亮显示以及自己定义高亮显示颜色
1.方法一:alt+shift+o 打开/关闭,该功能 2.方法二:windows-> preferences->java->Editor->Mark Occurences ( ...
- 2016/3/18 ①PHP基础 ② PHP函数 ③其他函数(随机数、关于日期) ④正则表达式 ⑤字符串处理
一.PHP基础 1,标记和注释 ①<?php?> ②单行注释// 多行注释/** */2, 输出语句 ①echo输出 echo可以输出多个字符串,用逗号隔开. ②print输出 pr ...
- shell 读写远程数据库
http://www.cnblogs.com/wangkangluo1/archive/2012/04/27/2472898.html 利用Shell脚本实现远程MySQL自动查询 目的:对定时任务对 ...
- DataTabless Add rows
参考官网案例:https://datatables.net/examples/api/add_row.html JS: $(document).ready(function() { var t ...
- docker启动centos容器后如何用putty连接
在前面的文章中,我提到过,win10 docker启动容器时,只有配置了宿主机和docker容器的端口映射,外部应用才能访问到容器中的服务,比如映射到Nginx的80端口.现在我将宿主机的某个端口映射 ...
- 在 linux 下使用 CMake 构建应用程序【转】
本文转载自:https://www.ibm.com/developerworks/cn/linux/l-cn-cmake/index.html CMake 简介 CMake 是一个跨平台的自动化建构系 ...
- Expression Blend实例中文教程系列
Expression Blend实例中文教程系列 本系列文章均转载:银光中国 时间:2010-04-09 09:20责任编辑:银光中国网 点击:次 Expression Blend实例中文教程系列由C ...
- Servlet单例非安全解析
Servlet容器默认是采用单实例多线程的方式处理多个请求 Servlet容器<Web容器<应用服务器?apache<tomcat<websphere Servlet不是线程安 ...
- J20170524-hm
取りこぼし 意外地输给较自己实力弱的对手,爆出冷门,败给手下败将 振り分け 分配,整理 スキーマ 图解.模式.图式
- [App Store Connect帮助]八、维护您的 App(4.2)查看评分与评论
您可以查看 App 的总评分或单个顾客评论.如有必要,您可以针对某条评论报告问题. [注]顾客可以为您的 iOS 和 macOS App 评分并撰写评论,但只能为 Apple TVOS App 评分. ...