The foundation kit is the base Class library for OS X class Library and iOS class library sharing, which provides a lot of encapsulation classes, see https://developer.apple.com/library/ios/documentation/Cocoa/ reference/foundation/objc_classic/, here are some common classes.
1. String class: NSString and Nsmutablestring.
Nsmutablestring inherit from NSString, the difference is: Nsmutablestring is mutable, and NSString is immutable. This means that when the string has been determined, nsstring cannot delete and add the string, and nsmutablestring solves the problem.
The following code:
nsstring* pStr1 = @ "Hello";
[PStr1 stringbyappendingstring:@ "World"]; PStr1 or Hello?
nsmutablestring* pmtstr = [nsmutablestring stringwithformat: @ "Hello"];
[Pmtstr appendString: @ "World"]; Pmtstr for Hello World
PSTR1 calls the method stringbyappendingstring after pStr1 or Hello,pmtstr calls the method appendstring after pmtstr directly changes to Hello World. So how do we make pStr1 into Hello world? Very simple: PStr1 = [pStr1 stringbyappendingstring:@ "World"], this achieves the same effect as Pmtstr appendstring.
2. Dynamic arrays: Nsarray and Nsmutablearray, the difference is similar to NSString and nsmutablestring. The dynamic array is similar to the vector inside the STL.
3. List: I did not find similar to the C + + STL inside the list implementation, have to know the classmate please tell me.
4.set collection: Nsset, Nsmutableset, and Nscountedset.
At first I thought Nsset was similar to the C + + set, and after looking at the document, Nsset didn't sort the objects, but nsset guaranteed the uniqueness of the objects.
NSString *pstr1 = @ "C"; NSString *PSTR2 = @ "B"; NSString *PSTR3 = @ "a"; NSString *PSTR4 = @ "C"; nsset* MySet = [Nsset setwithobjects:pstr1, PSTR2, PSTR3, PSTR4, nil];
The above code inside MySet object is b,c,a.
5.MAP implementations: Nsdictionary and Nsmutabledictionary, similar to the map in C + +.
6. Question: Does OC have similar multiset, Multimap, list, stack, deque implemented in C + +? At present I do not find in the document similar class, have to know the friend can tell me, thank you!
Foundation Kit Common Class Introduction