Notes on new syntax features of objective-C

Source: Internet
Author: User
Document directory
  • Nsnumber Value assignment:
  • Nsarray assignment and access:
  • Nsdictionary assignment and access:
New syntax features of objective-C 1. Improvement of enumeration types

Previously, I declared that the enumeration method is based on the C ++ habit:

Typedef Enum {HUMAN, monkey, chiecken, cow} animals;

The new statement is as follows:

Typedef Enum animals: nsuinteger {HUMAN, monkey, cow} animals;

Enum can be bound to the data type.

2. nsnumber assignment in simplified Syntax:
Nsnumber * value; value = @ 12345; value = @ Yes; value = @ 3.14f;
Nsarray assignment and access:
Nsarray * array; array = @ {1, 2, 3}; array = @ {A}; array [I] = 23;
Nsdictionary assignment and access:

Nsdictionary * dict;
Dict =@{ key1: obj1, key2: obj2 };
Dict = @{};
Dict [key1] = obj3;

Summary

Although, it's just some simple syntactic sugar. But it makes objective-C easier to use. That is, how does one feel more and more like C #/Java?

Related Article

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.