iT邦幫忙

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

iOS 筆記系列 第 19

File's Owner 系列 part 2

  • 分享至 

  • xImage
  •  

這個主題會有 part 2 是因為 part 1 的答案實在沒辦法滿足我,但很不幸地似乎那是少數相關的官方文件,所以 part 2 整理我在網路上找到其他人的回答。

知乎上找到更舊的文件,有稍微詳細點的解釋:

File’s Owner Represents the nib file’s controller object. File’s Owner is the most commonly used placeholder object in nib files and is supported by both Mac OS X and iOS nib files. The File’s Owner placeholder is the main bridge between your application and the contents of the nib file.

When you build and run your application, the nib-loading code substitutes the object that is the file’s owner for any references to the File’s Owner placeholder in the nib file. This substitution results in the outlets and actions connected to the File’s Owner placeholder being connected to the object that is the file’s owner.

You can designate any object in your application as the File’s Owner of a nib file. You tell Interface Builder the class of the File’s Owner so it knows what connections to make available. Typically, the file’s owner is a controller class that manages the interactions with the views and other controller objects inside the nib file.

其中第一句「File’s Owner Represents the nib file’s controller object.」差不多有解答我在 part 1 提出的疑問了,這也是為什麼那那裡是放 Controller。

總結一下:

  1. File’s Owner 是這個 nib file 的 controller object
  2. File’s Owner 負責連結這個 nib file 裡的內容跟其他 apllication

另外我有找到這篇非常詳細的解釋:Cocoa: What is "File's Owner" in a nib?


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

尚未有邦友留言

立即登入留言