The root of the Foundation class hierarchy is the NSObject class, which (along with NSObject and NSCopying protocols) defines basic object properties and behavior. The rest of the Foundation framework consists of several groups of interrelated classes and some independent classes. There are some classes that represent basic data types, such as strings, byte arrays, and collection classes for storing other objects; some classes that represent system information, such as dates; and some classes that represent system entities, such as ports and threads. , And process. The class hierarchy shown in Figures 1, 2, and 3 describes the logical grouping and inheritance of these classes.
The root of the Foundation class hierarchy is the NSObject class, which (along with NSObject and NSCopying protocols) defines basic object properties and behavior.
The rest of the Foundation framework consists of several groups of interrelated classes and some independent classes. There are some classes that represent basic data types, such as strings, byte arrays, and collection classes for storing other objects; some classes that represent system information, such as dates; and some classes that represent system entities, such as ports and threads. , And process. The class hierarchy shown in Figures 1, 2, and 3 describes the logical grouping and inheritance of these classes.
Founddation part one
Foundation Continued
Founddation part two
Founddation part three
The above block diagrams logically classify the classes in the Foundation framework according to the following categories (and other associations mentioned below):
Value object. Value objects encapsulate various types of data, and provide access to data and various operations. Because they are all objects, they (and the values they contain) can be archived and distributed. The NSData class provides object-oriented storage space for byte streams, while the NSValue and NSNumber classes provide object-oriented storage space for simple scalar value arrays. The NSDate, NSCalendarDate, NSTimeZone, NSCalendar, NSDateComponents, and NSLocale classes provide objects representing time, date, calendar, and locales. The methods they contain can be used to calculate the date and time difference, display the date and time in various formats, and adjust the time and date at various locations in the world.
String. NSString is another type of value object, which is responsible for providing object-oriented storage space for byte arrays with a specific encoding ending in null. It supports conversion between UTF-16, UTF-8, MacRoman, and many other encoded strings. NSString also provides methods for searching, combining, and comparing character strings, and manipulating file system paths. You can use the NSScanner object to parse the numbers and words in the NSString object. NSCharacterSet (the part of the collection class shown in the block diagram) represents a set of characters that can be used in various NSString and NSScanner methods.
Set. Collections are objects that store and access other objects (usually numeric values) in a certain order. The index of NSArray starts from 0, NSDictionary uses key-value pairs, and NSSet is responsible for the random storage of objects (NSCountedSet class makes the collection uniquely identified). Through the NSEnumerator object, you can access the sequence of elements in a collection. The collection object is a necessary element of the attribute list, and like all other objects, it can also be archived and distributed.
Operating system services. Many Foundation classes provide convenience for accessing various underlying operating system services, while at the same time isolating developers from the specific characteristics of the operating system. For example, you can query the environment in which the application is running through the NSProcessInfo class; get the name and address of the host system on the network through the NSHost class; through the NSTimer object, you can send messages to other objects at specified intervals; NSRunLoop can help You manage input sources for applications or other types of programs; NSUserDefaults provides programming interfaces for system databases that store global (host-level) and user-level defaults (presets).
File system and URL. NSFileManager provides a unified interface for file operations such as creating, renaming, deleting, and moving files. NSFileHandle can perform relatively low-level file operations (such as search operations within the file). NSBundle can find resources stored in the package and can dynamically load certain resources (such as nib files and code). You can use the NSURL and NSURLHandle classes to represent, access, and manage data derived from URLs.
Interprocess communication. Most of the classes in this category represent different system ports, sockets, and name servers, and are useful for implementing low-level IPC. NSPipe represents a BSD pipe, a unidirectional communication channel between processes.
Threads and subtasks. The NSThread class allows you to create multi-threaded programs, and various lock classes provide various control mechanisms for competing threads to access process resources. Through NSTask, your program can be divided into a sub-process to perform other work or progress monitoring.
Archive and serialize. Classes in this category make object distribution and persistence possible. NSCoder and its subclasses, together with the NSCoding protocol, can represent the data contained in an object in an architecture-independent manner, and can store class information and data together.
Expression and condition judgment. Condition judgment classes, namely NSPredicate, NSCompoundPredicate, and NSComparisonPredicate classes, are responsible for encapsulating the logical constraints of acquiring or filtering objects. The NSExpression object represents the expression in the conditional judgment.
Spotlight query. NSMetadataItem, NSMetadataQuery and related query classes encapsulate the file system metadata, making metadata query possible.
Objective-C language service. The NSException and NSAssertionHandler classes provide object-oriented encapsulation for assertions and exception handling in code. The NSInvocation object is a static representation of an Objective-C message, and your program can store it and use it later to activate another object's message. Undo Manager (NSUndoManager) and Distributed Objects (Distributed Objects) systems use this type of object. The NSMethodSignature object is responsible for recording method type information, which can be used to push information. NSClassDescription is an abstract class, used to define and query the relationship and properties of the class.
script. The classes in this category can help you implement support for AppleScript scripts and Apple Event commands.
Distributed objects. You can use distributed object classes to communicate between processes on the same computer or on different computers in a network. Two of the classes-NSDistantObject and NSProtocolChecker have different root classes (NSProxy) and other parts of Cocoa.
The internet. The NSNetService and NSNetServiceBrowser classes support a zero-configuration network architecture called Bonjour. Bonjour is a powerful system for publishing and browsing services on IP networks.
Support