What is the difference between Object and External Object in the IB?
When should I use each?
Adding on to the other answer: You could use an 'External Object' to access a common object across multiple xib's. You could do this in other ways too, but this would be convenient.
Like for example, if you have a 'big' action to be performed for button clicks over multiple xib's and if you have many such actions (and additionally if it's the same data you are performing this action on), instead of calling addTarget:action...
, you could create the proxy object of this class and wire it up to the buttons.
You can connect the proxy object to your xib using the following code:
id *proxy = <someObject>; //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];
An Object is something that's actually embedded in the nib.
An External Object is one that the code that loads the nib promises to provide at load time (I believe via a dictionary that maps keys to external objects).
Most people never use any External Object besides File's Owner (which is already provided for you). You almost certainly just want Objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With