The cocoa foundation framework has many low-level data-oriented classes and data types, which are more efficient.
I. Range: nsange
typedef struct _NSRange { unsigned int location; unsigned int length;} NSRange;
1. nsange range;
Range. Location = 17;
Range. Length = 4;
2. nsange range = {17, 4 };
3. nsange range = nsmakerange (17, 4 );
Ii. Several Data Types
1,
typedef struct _NSPoint { float x; float y;} NSPoint;
2,
typedef struct _NSSize { float width; float height;} NSSize;
3,
typedef struct _NSRect { NSPoint origin; NSSize size;} NSRect;
Iii. String
1. Create a string
+ (id) stringWithFormat: (NSString *) format, ...;
+ Indicates a class method, which is similar to the static method of Java.
... Multiple parameters are accepted.
NSString *mString;mString = [NSString stringWithFormat: @"your height is %d feed, %d inches", 5,11];
2. Size
- (unsigned int) length;
3. Comparison
- (BOOL) isEqualToString: (NSString *) aString;- (NSComparionResault) compare: (NSString *) string;- (NSComarionResault) compare: (NSSting *) string option: (unsigned) mask;if ([thing1 compare: thing2 option: NSCaseInsensitiveSearch | NSNumericSeacch] ==NSOrderedSame) { NSLog (@"They match");}
4. Contain strings
-(Bool) haspreifx: (nsstring *) astring;-(bool) hassuffix: (nsstring *) astring;-(nsange) rangeofstring: (nsstring *) astring; // if not, nsnotfound is returned.
Iv. Variable string nsmutablestring
+ (id) stringWithCapacity: (unsigned) capacity;
V. Set
1. Immutable array nsarray: it can store any object. It cannot store basic data types or random pointers. It cannot store nil (zero or null values of the object)
2. variable array nsmutablearray
3. enumerate nsenumerator
4. Immutable dictionary nsdictionary: similar to map, hash
Variable dictionary nsmutablestring
Vi. Values
1. nsnumber: basic packaging class. Auto-boxing is not supported.
2. nsvalue: any value can be packaged.
3. nsnull: Nil cannot be added to the collection, but nsnull can be used to eliminate ambiguity.
[Nsnull null] always returns the same value. You can use = to compare it with other values.