0

In my implementation file, I write this:

@interface MyViewController () {
    __weak IBOutlet UILabel *lbl_example;
}

Should I write it with / without the __weak keyword?

How does it affect the memory / resource usage?

p.s. I understand that IBOutlet is just a keyword to help Interface Builder to link up codes with components in Interface; it has no actual effects on coding.

p.s. It's not about @property in header file. Different.

Raptor
  • 53,206
  • 45
  • 230
  • 366
  • with `__weak` means your view (not controller) own the outlet. without `__weak` means your controller (and view) own the outlet. in most the cases, they makes no different because the controller own the view and indirectly own the outlet – Bryan Chen Jun 16 '14 at 09:34
  • Hey @Wain The "duplicated" question is about `@property`. It's different. – Raptor Jun 16 '14 at 09:36
  • 1
    @Raptor Under ARC it's almost the same. The same answer applies there. – Sulthan Jun 16 '14 at 09:40
  • `@property` exposes variable to other classes, while in implementation, the variable remains private. Same? – Raptor Jun 16 '14 at 09:50
  • 1
    @Raptor Not true. You can make properties "private" (in class continuation). You can also make ivars "public" (in public interface header). No real difference there. More importantly, no difference for memory management. – Sulthan Jun 16 '14 at 10:02
  • @Raptor, there is no difference in this perspective whether the outlet is a property or a private ivar. – holex Jun 16 '14 at 11:00

0 Answers0