iOS SDK 4.3 學習筆記 iPhone101 (02)

來源:互聯網
上載者:User

在 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的專欄

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.