IOS Application core architecture
main.m
*appDelegate.h/.m
MainWindow.xib
*info.plist
IOS applications are encapsulated by UIKit, and the standard implementation of the main function of an Application application is as follows:
int main(int argc, char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
Among them, NSAutoreleasePool does automatic memory release, and autorelease suspends the release operation.The core is the UIApplicationMain() function, UIKit encapsulates the initialization work, loads the user interface of the application and starts the event loop. Its third and fourth parameters receive NSString* type parameters, which are used to specify the class name.
The third parameter specifies: UIApplication class. If the value of the primary class string is
nil
, UIKit uses the UIApplication
class by default; if it is not empty, the application uses the specified custom subclass of the UIApplication
class (This practice is not recommended, but it is indeed possible).The fourth parameter specifies: AppDelegate. If the app delegate class is
nil
, UIKit will assume an object in the app's main nib file (for apps created through the Xcode template) as the app's delegate object.UIApplication and AppDelegate
UIApplication is the core of the app application. It is responsible for the processing logic of events. It distributes application-related events such as touch screen processing to the corresponding FirstResponder, and notifies related operations down through AppDelegate. UIApplication is the processing core applicable to any application. It allows different programs to generate different actions and behaviors through AppDelegate.
main nib file
The default is MainWindow.xib, specified by NSMainNibFile in *info.plist. If the application's information property list (
Info.plist
) file contains a NSMainNibFile
key, the UIApplication
object loads the nib file specified by that key as part of the initialization process. The main nib file is the only nib file that is automatically loaded, other nib files can be loaded later as needed.The main nib file of an iPhone application usually contains a window object and an application delegate object, and may also contain one or more other important objects that manage windows. Loading a nib file causes the objects in the file to be reconstructed, converting the on-disk representation of each object into an in-memory object that the application can manipulate. There is no difference between objects loaded from a nib file and objects created programmatically. However, for user interfaces, it is often more convenient to create objects associated with the user interface graphically (using the Interface Builder program) and store them in nib files rather than programmatically.
The basic process of program startup of standard ViewBase project
Call UIApplicationMain() in the program entry main, the 3 and 4-bit parameters are default parameters, use the default UIApplication class, use the AppDelegate class specified in the NIB and set it to UIApplication. Load the NIB file, construct AppDelegate, create Window window, and create UIViewController. The application framework is started and completed, UIApplication processes and distributes the event logic, and the application executes normally in the event loop.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Swift의 패스트 패스Objective-C를 대체하기 위해 만들어졌지만 Xcode는 Objective-C 런타임 라이브러리를 사용하기 때문에 Swift와 함께 C, C++ 및 Objective-C를 컴파일할 수 있습니다. Xcode는 S...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.