"Object-c Study Notes" 8th Chapter Foundation Kit Introduction

Source: Internet
Author: User

1. Data type

1) Range

The first is a struct, which represents the range of related things, usually the range of characters in a string or the range of elements in an array.

1     struct _nsrange 2     {3         int location;   The starting position of this range is 4         int length;   The number of elements contained in this range is 5     }nsrange;

For example: "Object-c is a cool language", the word cool can be used location for 17,length to 4 of the range, location can also use the value of Nsnotfound to indicate that there is no scope, stating that the variable is not initialized.

There are three ways to create Nsrange:

(1) Assigning values directly to the field;

1     Nsrange range; 2      - ; 3     4;

(2) Application of C-language aggregation structure assignment mechanism

1     Nsrange range = {4};

(3) Cocoa provides a shortcut function Nsmakerange (): It can be used wherever functions can be used, such as in a method called to pass it as a parameter;

1 Nsrange range = Nsmakerange (17,4); [AnObject Flabulatewithrange:nsmakerange (13,15)];

"Object-c Study Notes" 8th Chapter Foundation Kit Introduction

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.