iOS SDK 4.3 学习笔记 iPhone101 (02)

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-02 02:40 点击:

在 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的专栏
    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • Lexical or Preprocessor Issue 'xxx.h
    • ios学习笔记(二)xcode 4.3.2下实现基本交互
    • ios版本的helloworld
    • iphone(object-c) 内存管理(3) 有效的内存管理 前半部分
    • ios学习笔记(一)xcode 4.3.2下创建第一个ios项目
    • IOS类似iphone通讯录TableView的完整demo【附源码】
    • UITableView一些方法
    • [iPhone中级]iPhone团购信息客户端的开发 (二)
    • iphone(object-c)内存管理(1)
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1