开发者

how to release controls created by ib

开发者 https://www.devze.com 2023-02-15 09:28 出处:网络
I used IB to created some UIView objects and used IBOutlet to link to my code.Some samples below: 1.IBOutletUIView *view1;

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 ;  @prop开发者_如何转开发erty(retain) IBOutlet UIView *view1;

what's the difference ? should I release them manually ?

Thanks for your help.


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


Please visit here .


You need to release manually all of the IBOutlets in

dealloc and set it nil in unload.


Hi you can release them in dealloc method manually.

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

}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号