当前位置:编程学习 > wap >>

iOS SDK 4.3 学习笔记 iPhone101 (02)

在 iPhone101.pdf P30 关于 File's Owner 有这样一段描述

 
In a nib file, in contrast to the other objects you add to the inte易做图ce, 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 Inte易做图ce 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.zzzyk.com这两段话的意思是 main nib file 由 application 处理,其他的 nib file 由 UIViewController (iOS) 和 NSViewController (Mac OS X) 处理。


摘自 pingjiang2003的专栏
补充:移动开发 , IOS ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,