一起来学Objective-C(2)——Hello World深入
来源:互联网 发布:西安淘宝设计代运营 编辑:程序博客网 时间:2024/05/01 08:24
上一节给出了hello world的程序,这里对该程序做进一步的详解,源代码如下:
- #import <Foundation/Foundation.h>
- int main(int arvc, char* argv[])
- {
- NSLog(@"Hello World!");
- return 0;
- }
1. Objective-C包含头文件的关键字为import,这主要源于gcc的支持,同时也支持include。import和include的主要区别是:采用import之后,无需在头文件中用#ifdef/#define/#endif来防止头文件被重复包含了,这一点类似于C#和Java
2. Function.h包含了所有的头文件
3. 暂且可以将NSLog看作是printf的封装,尽管没有这么简单
4. NSLog的前缀NS是NextSTEP的缩写,为了防止与其他函数名发生冲突
5. Cocal是一个库,其中均以NS作为前缀,Cocal类似于Boost
6. @表示是该字符串需要作为Cocal的NSString来处理,因为NSLog接收的参数为NSString
将源码改为:
- #include <stdio.h>
- int main(int arvc, char* argv[])
- {
- printf("Hello World!");
- return 0;
- }
也可以编译通过,所不同的是NSLog输出的内容比较多,比如时间信息。
一起来学Objective-C(1)——Window下开发环境安装和Hello World
一起来学Objective-C(2)——Hello World深入
一起来学Objective-C(3)——如何声明和定义类
- 一起来学Objective-C(2)——Hello World深入
- 一起来学Objective-C(2)——Hello World深入
- 一起来学Objective-C(1)——Window下开发环境安装和Hello World
- 一起来学Objective-C(1)——Window下开发环境安装和Hello World
- 一起来学Objective-C(1)——Window下开发环境安装和Hello World
- 一起来学Objective-C——Window下开发环境安装和Hello World .
- 一起来学Objective-C(4)——BOOL类型
- Objective-C第一站————hello world!!!
- Hello World"——Objective-C 学习笔记(1.1)
- 第一个Objective-C程序——Hello World!
- Android程序员快速入门Objective-C ——Hello World
- 一起来学Objective-C(3)——如何声明和定义类
- 一起来学Objective-C(3)——如何声明和定义类
- 一起来学Android Studio:(一)Hello world
- 《Hello World——C#》
- Objective-C学习笔记(三)——用Objective-C编写第一个程序:Hello,World!
- 黑马程序员——Objective-C简介 与 “Hello World”的编写
- Objective-C 2.0 从Hello,World!开始
- Mysql中Profiling之性能分析
- Java中范型的作用
- Struts2访问或者添加request等属性
- 一起来学Objective-C(1)——Window下开发环境安装和Hello World
- poll, select & poll—wait底层数据结构
- 一起来学Objective-C(2)——Hello World深入
- Bootargs使用
- CString
- Unix/linux解压tar命令
- 惠普笔记本LED灯闪烁代码故障含义
- 一起来学Objective-C(3)——如何声明和定义类
- windows下oracle导入数据脚本 bat
- Objective-C iPhone起步开发的8条建议和技巧
- objc 语法