iT邦幫忙

2017 iT 邦幫忙鐵人賽
DAY 18
0
自我挑戰組

iOS 筆記系列 第 18

File's Owner 系列 part 1

  • 分享至 

  • xImage
  •  

首先這是個在 nib 才有的東西我們先來看看官方文件 Resource Programming Guide 的解釋:

One of the most important objects in a nib file is the File’s Owner object. Unlike interface objects, the File’s Owner object is a placeholder object that is not created when the nib file is loaded. Instead, you create this object in your code and pass it to the nib-loading code. The reason this object is so important is that it is the main link between your application code and the contents of the nib file. More specifically, it is the controller object that is responsible for the contents of the nib file.

In Xcode, you can create connections between the File’s Owner and the other interface objects in your nib file. When you load the nib file, the nib-loading code recreates these connections using the replacement object you specify. This allows your object to reference objects in the nib file and receive messages from the interface objects automatically.

老實講說的並沒有很清楚,最重要的是這兩句:「The reason this object is so important is that it is the main link between your application code and the contents of the nib file. More specifically, it is the controller object that is responsible for the contents of the nib file.」

簡單講就是:File's Owner 是 nib file 跟 application 的連結

不過這還是沒辦法解釋到底為什麼當我要客製化一個 UIController 時,File's Owner 的 custom class 要填 UIController,然後 nib file 是要拖一個 UIView,為什麼不是拖一個 UIViewController 進來?


上一篇
ScrollView
下一篇
File's Owner 系列 part 2
系列文
iOS 筆記30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言