-An IBOutlet is for hooking up a property to a view when designing your XIB.
-An IBOutlet lets you reference the view from your controller code.
iOS Interview Questions And Answers Part 10
iOS Interview Questions And Answers Part12
2.What is IBAction in iOS?
Answer:-
-IBAction is a macro defined to denote variables and methods that can be referred to in Interface Builder.
-If you're not going to be using Interface Builder at all, then you don't need it in your code, but if you are going to use it, then you need to specify IBAction for methods that will be used in IB.
-IBAction is used to hook up your interface made in Interface Builder with your controller.
-IBAction is a special method triggered by user-interface objects. Interface Builder recognizes
them. An IBAction is for hooking a method (action) up to a view when designing your XIB.
-IBAction resolves to void .
- An IBAction is for hooking a method (action) up to a view when designing your XIB.
. An IBAction lets the view call a method in your controller code when the user interacts with the view.
Read:
Basic iOS interview Questions And Answers
Top 5 Frequently Asked iOS Interview Questions And Answers.
3.Should IBOutlets be strong or weak under ARC?
Answer:-
Instance variables under ARC are strong by default.
General rule of thumb, anything with an IBOutlet should be declared as weak.
According to rule of thumb:
When a parent has a reference to a child object, you should use a strong reference. When a child has a reference to its parent object, you should use a weak reference or a unsafe_unretained one (if the former is not available).
Read:
Best Tutorials- Properties in objective C
4.What is Strong in objective-c?
Answer:-
Strong
A strong reference (which you will use in most cases) means that you want to "own" the object you are referencing with this property/variable.
The compiler will take care that any object that you assign to this property will not be destroyed as long as you (or any other object) points to it with a strong reference.
Only once you set the property to nil will the object get destroyed (unless one or more other objects also hold a strong reference to it)
Read:
Why properties are made nonatomic in Objective C?
iOS Interview Questions And Answers Part 13
5.What is Weak in Objective-c?
Answer:
A weak reference you signify that you don't want to have control over the object's lifetime. The object you are referencing weakly only lives on because at least one other object holds a strong reference to it.
Once that is no longer the case, the object gets destroyed and your weak property will automatically get set to nil.
Example:-
Delegate properties, which are often referenced weakly to avoid retain cycles, and
subviews/controls of a view controller's main view because those views are already strongly held by the main view.
Read:
Top iOS Interview Questions And Answers for Beginners
iOS Interview Questions with Answers part4
iOS Interview Questions And Answers part12