-3

I am (trying to) learn Objective-C and I keep coming across a phrase like:

__weak IBOutlet NSLayoutConstraint *webViewLeftConstraint;

What does __weak it mean exactly in Objective-C? Why we need to put __(underscore twice) in variable? Can we use only one time? like( _ ) other declaration in other language..

Ronak Chaniyara
  • 5,225
  • 3
  • 23
  • 50
NemSothea
  • 159
  • 1
  • 1
  • 10

1 Answers1

1

If the outlet is referencing a UI Object in the View hierarchy then you should make it weak as the view hierarchy already has a strong reference.

Weak is specifically needed to avoid a retain cycle.

Arpit Jain
  • 1,530
  • 11
  • 23