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