Objective-C (introduction to the Foundation framework) 05-Introduction to the foundation framework
The so-called framework in iOS is a directory. iOS provides many frameworks that we can call in applications. Many applications use frameworks such as Foundation, UIKit, and Core Graphics. According to the template you selected for the application, the related framework has been automatically introduced. For example, when we create an Xcode project in CommandLineTool under OSX Application, the system will introduce the Foundation framework by default: # import <Foundation/Foundation. h> If the default framework cannot meet your application requirements, you can also add the framework you need. To use a framework, you need to add it to the project you created before your project can use it. When developing iOS projects, the most important frameworks used are the Foundation and UIKit frameworks. The Fundation framework provides basic system services for all applications, and the UIKit framework provides user interface-based classes.
Basic Framework for iOS
Framework name |
Function |
Foundation |
Provides basic OC classes (such as NSObject and NSString) and basic data types. |
UIKit |
User Interface for creating and managing applications |
QuartzCore |
Provides animation effects and hardware rendering capabilities |
CoreGraphics |
Provides a C-based API for 2D rendering. |
SystemConfiguration |
Checks whether the current network is available and the status of hardware devices |
AVFoundation |
Provides underlying APIs for audio recording and playback, and manages audio hardware. |
CFNetwork |
Access and configure the network, such as HTTP, FTP, And Bonjour Services. |
CoreFoundation |
Provides abstract common data types, such as Unicode strings, XML, and URL. |
CoreLocation |
Use GPS and WIFI to get location information |
GameKit |
Provides network functions for games: point-to-point interconnection and voice communication in games |
AddressBook |
Provides the ability to access user contact information |
AddressBookUI |
Provides a user interface for displaying the contact information stored in the address book. |
AudioToolBox |
Provides underlying APIs for audio recording and playback, and manages audio hardware. |
AudioUnit |
Provides an interface for our applications to Process audio. |
MapKit |
Provides an embedded map interface for Applications |
MediaPlayer |
Supports video and audio playback. |
MessageUI |
Provides a view control interface to process E-mail and text messages. |
OpenGLES |
Provides animation effects and hardware rendering capabilities |
StoreKit |
Provides applications with support for consumption during program running. |
And common third-party open-source frameworksAFNetworking and so on.
Foundation framework
(The framework in some official documents of apple is on the left, and header files of classes under some Foundation frameworks are displayed on the right)
The so-calledFoundation. frameworkThat is, Apple encapsulates some of our common classes into this framework. Common classes include NSString, NSDate, NSArray, NSDictionary, NSSet, and NSNumber. Classes in OC can be dividedImmutable)Class andMutable)Class, the Instance Object of the immutable class is called an immutable object, it refers to the object that cannot change its content after creation. A variable class instance object is called a variable object. It refers to an object that can change its content or status after being created. with Foundation, we can:
- Create and manage collections, such as arrays and dictionaries
- Access images and other resources stored in applications
- Create and manage strings
- Submit and receive notifications
- Creation date and time object
- Automatically discovers devices on an IP network.
- Operation URL stream
- Execute asynchronous code
Then, we need to learn about the classes provided by the system. We can:
1. Learn to useApplication Programming Interface (Application Programming Interface)Document
2. view the Class header file directly.
Option + left mouse button to enter the class API documentation (beginner)
Command + left-click to enter the Class header file by viewing the header file, suitable for those who have a certain understanding of this class.
3. What keywords should I pay attention to when viewing the API documentation?
Which class does Inherits from inherit from?
Conforms to indicates which protocols the class follows
The Framework class is defined under that Framework
Availability: Which version of iOS does this class support?
Declared in statement