Start learning object-C from "Hello World"
//// main.m// Demo1//// Created by lee on 14/10/27.// Copyright (c) 2014年 lee. All rights reserved.//#import <Foundation/Foundation.h>int main(int argc, const char * argv[]) { @autoreleasepool { // insert code here... NSLog(@"Hello, World!"); } return 0;}
1. Object-C Annotation
Object-C has two main annotation Methods: one is (// annotation, single line annotation), and the other is (/**/, multi-line annotation)
2. # import <Foundation/Foundation. h>
Importing system files mainly involves some basic classes and Methods
[Email protected] {} is used to create an automatic release pool.
The automatic release pool is a memory recovery mechanism in OC. Generally, some temporary variables can be added to the automatic release pool for unified recovery and release. When the automatic release pool is destroyed, all objects in the pool call release once, that is, the counter is reduced by 1, but the automatically released pool is destroyed, and the objects in the pool are not necessarily destroyed.
4. nslog (); outputs functions on the console
Nslog is equivalent to printf in C language and is often used for text output.
[Email protected] "Hello World"
The @ symbol before the string is called the constant nsstring object. In object-C, the classes used to process strings are nsstring and nsmutablestring. The main difference between these classes is that the content and length of strings cannot be dynamically changed after nsstring is created, while nsmutablestring can dynamically change the content and length of the string.
6. Return 0;
It indicates the termination of the main function and returns a state value of 0. According to the Convention, 0 indicates that the program ends normally.
Learning Object-C from scratch --- first day