Search code examples
iphonenibiboutlet

when to use a IBOutlet?


I'm a little confused about the IBOutlet.Is it right I should use the IBOutlet when the variable will be changed in the nib?


Solution

  • IBOutlet is used when you want to do something with a View you created in Interface Builder. For example, you put a button in Interface Builder and you want to change it's caption/label from your code, attach IBOutlet (with a name such as button1) to that button. Then from your code, you can call [button1 dosomething]. Without having IBOutlet, you have virtually no way to do some action to a View you created in Interface Builder. Short answer is yes, always use IBOutlet whenever you want to do something with a View created in Interface Builder.