0

I used IB to created some UIView objects and used IBOutlet to link to my code.
Some samples below:

1.  IBOutlet  UIView *view1;

2.  IBOutlet  UIView *view1;  @property(retain)  UIView *view1;

3.  UIView *view1 ;  @property(retain) IBOutlet UIView *view1;

what's the difference ? should I release them manually ?
Thanks for your help.

Robin
  • 10,011
  • 5
  • 49
  • 75
ywss
  • 11
  • 1
  • 3

4 Answers4

1

You should remove it manually....

your third statement would work correctly... as Xcode identifies nib controls from its property declaration and not from inside class declaration.

(in side class)

IBOutlet  UIView *view1;

Interface builder probably won't recognize it as IBoutlet as it is declared only inside the class. (class variable are protected)

IBOutlet  UIView *view1;  @property(retain)  UIView *view1;

Interface builder probably won't recognize it as IBoutlet as it is declared only inside the class. (class variable are protected)

3.  UIView *view1 ;  @property(retain) IBOutlet UIView *view1;

correct way Interface builder will recognize it. and it will show it when you connect referencing outlet from your Interface builder

Mihir Mehta
  • 13,743
  • 3
  • 64
  • 88
0

Please visit here .

Community
  • 1
  • 1
makboney
  • 1,808
  • 1
  • 17
  • 34
0

You need to release manually all of the IBOutlets in

dealloc and set it nil in unload.

Ishu
  • 12,797
  • 5
  • 35
  • 51
-1

Hi you can release them in dealloc method manually.

- (void)dealloc {
  [view1 release];
  [view2 release];
  [super dealloc];

}
Mayur Birari
  • 5,837
  • 8
  • 34
  • 61
  • 2
    Never call [super dealloc] first. That always goes last. You tear down your subclass's state, *then* let the object be destroyed. – Catfish_Man Mar 07 '11 at 06:50