XCode Interface Builder中的对象与外部对象

IB中对象和外部对象有什么区别?
我什么时候应该使用?

添加到另一个答案:您可以使用“外部对象”来访问多个xib的公共对象。 你也可以用其他方式做到这一点,但这很方便。

例如,如果您对多个xib上的按钮点击执行“大”操作,并且您有许多此类操作(此外,如果它与您执行此操作的数据相同),而不是调用addTarget:action... ,您可以创建此类的代理对象并将其连接到按钮。

您可以使用以下代码将代理对象连接到xib:

  id *proxy = ; //The object you want to wire up //In the below line of code use the same key as the identifier you give for the proxy object in the Interface Builder UINib *nib = [UINib nibWithNibName:@"ViewController" bundle:Nil]; NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:proxyObject,@"proxy", nil]; NSDictionary *dict2 = [NSDictionary dictionaryWithObjectsAndKeys:dict,UINibExternalObjects, nil]; NSArray *nibArray = [nib instantiateWithOwner:self options:dict2]; self.view = [nibArray objectAtIndex:0]; 

对象实际上是嵌入在笔尖中的东西。

外部对象是加载nib的代码承诺在加载时提供的对象(我相信通过将键映射到外部对象的字典)。

除文件所有者(已经为您提供)之外,大多数人从不使用任何外部对象。 你几乎肯定只想要对象。