Object-c Study (v)--foundation Framework (i)

Source: Internet
Author: User

First, the framework is understood: The framework is a collection of classes, methods, functions, and documents organized according to certain rules, so that the program apes can be developed more conveniently and quickly.

About Foundation framework: It is the cocoa program that is written mainly for 2 framework Foundation and Applicationkit (UIKit).

Foundation
| | | | | |
NSString Nsarray Nsdictionary Nsset Nsvalue NSDate
| | | |
Nsmutablestring Nsmutablearray Nsmutabledictionary Nsmutableset Nsmutablevalue

First, NSObject class

NSObject class is the root class of all classes, he does not have a parent class, all OC objects directly or indirectly inherit the NSObject class.

Common methods:

1. Compare two pointers to the same object (whether the pointer points to the same chunk of memory)

-(BOOL) IsEqual: (ID)object;

2. Call a method

-(ID) performselector: (SEL) aselector;

3. Call a method and pass a parameter

-(ID) performselector: (SEL) aselector withobject: (ID)object;

4, call a method, pass two parameters

-(ID) performselector: (SEL) aselector withobject: (ID) object1 withobject: (ID) Object2;

5. Whether an object is derived or belongs to a class

-(BOOL) Iskindofclass: (Class)class;

6. Whether an object belongs to a certain class

-(BOOL) Ismemeberofclass: (Class)class;

7. Whether an object responds to a specified method

-(BOOL) Respondstoselector: (SEL) aselector;

Ii. NSString and Nsmutablestring

#import<Foundation/Foundation.h>intMainintargcConst Char*argv[]) {@autoreleasepool {//string ConstantsNSString *STR1 =@"Yinhao"; NSString*STR2 =@"Ihoou"; //Create a stringNSString *STR3 = [[NSString alloc] Initwithformat:@"%@,%@", STR1,STR2]; NSString*STR4 =@"Yinhaoihoou"; //string comparison        if([Str3 ISEQUALTOSTRING:STR4]) {NSLog (@"%@ and%@ strings are equal", STR3,STR4); }        Else{NSLog (@"%@ and%@ strings are equal", STR3,STR4); }                //string InterceptionNSString *STR5 =@"abcedfghijklmnopqrstuvwxyz"; NSString*STR6 = [STR5 substringfromindex:5]; NSLog (@"STR5 string STR6 equals%@ after the string is truncated from the 5th position", STR6); //Find StringNsrange range = [STR5 rangeofstring:@"UVW"]; if(Range.location! =nsnotfound) {NSLog (@"location=%ld,length=%ld", Range.location,range.length
View Code

Object-c Study (v)--foundation Framework (i)

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.