在iPhone中文件所有者,第一响应者和应用程序委托的概念 [英] The concept of file's owner,first responder, and application delegate in iPhone

查看:100
本文介绍了在iPhone中文件所有者,第一响应者和应用程序委托的概念的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

iPhone界面生成器和代理

这三个组件在Objective C / iPhone世界?我发现App Delegate与UI和代码中的变量有一些关系。它匹配视图上的变量和相关的UI对象。但我发现文件的所有者有称为委托的出口相关的应用程序委托,他们的关系是什么。此外,第一反应者,它似乎只是收到一些效果。

What is the relationship between these three component in the Objective C / iPhone world? I found that the App Delegate have some relationship with the UI and the variable in code. It match the variable and related UI object on the view. But I found that the File's owner have the outlet called delegate that related to the Application delegate, what is their relationship. Also, the first responder, it seems it just receive some effect only. What's going on between there stuff?

推荐答案

一次一个:


  • 文件的所有者:这是加载xib文件的对象。在完全通用的意义上,这是作为owner参数传递给 - [NSBundle loadNibNamed:owner:] 的对象。当为一个 UIViewController 子类使用nib时,这通常是 UIViewController 子类本身。进一步阅读:资源编程指南:Nib文件

  • 第一响应者:这是首先接收非目标事件(即发送目标为 nil 的事件)的视图。其有用的部分是,它连接到响应者链的想法,这是一个机制,通过它,在视图层次结构中更高的事物可以捕获未处理和处理它们。这个概念源于Mac,对于实现像复制菜单项这样的东西特别有用。第一个响应程序是复制菜单项的目标,这意味着所选文本字段有可能先处理复制事件,然后处理其复制事件,等等。进一步阅读: iPhone应用程序编程指南:事件处理

  • 应用程序委托:这只是应用程序 UIApplication object。它通常接收关于应用程序的一般状态消息,例如当它开始,​​结束和什么不。这是一个很好的起点,当你的应用程序启动或关闭需要发生的事情。进一步阅读: Cocoa基础指南:代表和数据源

  • File's Owner: This is the object that loads the xib file. In a completely generic sense, this is the object passed as the owner parameter to -[NSBundle loadNibNamed:owner:]. When working with a nib for a UIViewController subclass, this is usually the UIViewController subclass itself. Further reading: Resource Programming Guide: Nib Files
  • First Responder: This is the view that receives untargeted events (i.e. those sent with a target of nil) first. The useful part of this is that it's connected to the idea of the responder chain, which is a mechanism by which things higher up in the view hierarchy can capture unhandled and deal with them. This concept originated on the Mac, and is particularly useful for implementing something like the "Copy" menu item. The first responder is the target of the "Copy" menu item, meaning that the selected text field gets a chance to handle the copy event first, then its superview, and so on. Further reading: iPhone Application Programming Guide: Event Handling
  • Application Delegate: This is simply the delegate of the application's UIApplication object. It typically receives general status messages about the application, such as when it starts, ends and what not. It's a good spot to kick off things that need to happen when your app starts or shuts down. Further reading: Cocoa Fundamentals Guide: Delegates and Data Sources

希望有帮助。

这篇关于在iPhone中文件所有者,第一响应者和应用程序委托的概念的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆