Learning Object-C from scratch --- first day

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.