你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS SDK 4.3 學習筆記 iPhone101 (02)

iOS SDK 4.3 學習筆記 iPhone101 (02)

編輯:IOS開發綜合

在 iPhone101.pdf P30 關於 File's Owner 有這樣一段描述

 
In a nib file, in contrast to the other objects you add to the interface, the File’s Owner object is not created when the nib file is loaded. It represents the object set to be the owner in the method that loads the nib file—in this case, loadNibNamed:owner:options:. This is discussed in more detail in Resource Programming Guide. In your application, the File’s Owner will be the instance of MyViewController.
 
這段話的意思是 nib 文件中的大部分對象都是在 nib 文件被 load 的時候創建的,只有 File’s Owner 對象不是。它是 load 這個 nib 文件的方法 (在這裡,是 loadNibNamed:owner:options:)中的 owner 。在 Resource Programming Guide 裡有更詳細的描述。在這個 application 中,File’s Owner 是 MyViewController 的一個實例。
 
我的理解是 File's Owner 指的是這個 nib 文件的擁有者,它需要負責創建和銷毀這個 nib 文件中的對象。loadNibNamed:owner:options: 這個方法我沒有找到,估計是在框架中。
 
Resource Programming Guide
 
The Application Loads the Main NIb File
Most of the Xcode project templates for applications come preconfigured with a main nib file already in
place. All you have to do is modify this default nib file in Interface Builder and build your application. At
launch time, the application’s default configuration data tells the application object where to find this nib
file so that it can load it. In applications based on either AppKit and UIKit, this configuration data is located
in the application’s Info.plist file. When an application is first loaded, the default application startup code
looks in the Info.plist file for the NSMainNibFile key. If it finds it, it looks in the application bundle for
a nib file whose name (with or without the filename extension) matches the value of that key and loads it.
 
Each View Controller Manages its Own Nib File
The UIViewController (iOS) and NSViewController (Mac OS X) classes support the automatic loading
of their associated nib file. If you specify a nib file when creating the view controller, that nib file is loaded
automatically when you try to access the view controller’s view. Any connections between the view controller
and the nib file objects are created automatically, and in iOS, the UIViewController object also receives
additional notifications when the views are finally loaded and displayed on screen. To help manage memory
better, the UIViewController class also handles the unloading of its nib file (as appropriate) during
low-memory conditions.
 
For more information about how you use the UIViewController class and how you configure it, see View
Controller Programming Guide for iOS.
 
www.2cto.com這兩段話的意思是 main nib file 由 application 處理,其他的 nib file 由 UIViewController (iOS) 和 NSViewController (Mac OS X) 處理。


摘自 pingjiang2003的專欄
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved