[Objc] Foundation Kit

Source: Internet
Author: User

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.

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.