IBOutlets strong or weak

Sockets can be created as follows

@interface SearchViewController : UIViewController<UISearchBarDelegate> { IBOutlet UIView *viewSearchBar; IBOutlet UIScrollView *scrollVieww; IBOutlet UILabel *lblName; } 

as well as

 @interface SearchViewController : UIViewController<UISearchBarDelegate> { } @property(nonatomic, weak) IBOutlet UIScrollView *scrollVieww; @property(nonatomic, weak) IBOutlet UIView *viewSearchBar; @property(nonatomic, weak) IBOutlet UILabel *lblName; @end 

I know nonatomic / atomic strong / weak in ARC, but in the first example, what is it? strong , weak , nonatomic or atomic .

Please explain or relate me to some details.

+7
source share
3 answers

Instance variables in ARC are strong by default. And they are neither atomic nor non-atomic, because they are just instance variables, not access methods. Atomic / non-atomic flags are associated with multi-threaded threads. They indicate whether atomic access methods should be atomic. When the accessor is atomic, execution cannot be changed to another thread in the middle of the access method. When it is non-nuclear, there is no such limitation.

Note. IBOutlet is typedef nothing. This is just a flag for Interface Builder and has no memory related features.

+7
source

Variables are __strong by default in ARC, therefore:

IBOutlet UIView *viewSearchBar;

coincides with

IBOutlet __strong UIView *viewSearchBar;

Regarding the recommended way to work with IBOutlets in ARC, see the answer to this question.

+5
source

General rule, everything with IBOutlet should be declared weak.

Take a look at weak or strong for IBOutlet and others .

+3
source

All Articles