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)