IBOUTLET的东西是否需要release

关于iboutlet的东西是否需要释放,在stackoverflow上搜了一下,大致说

weak .arc不需要释放

其他情况需要释放

如:

1.

 have dilemma about Memory releasing IBOutlet object.Do anyone please suggest what to do when we create IBOutlet object without property, need to release it?? if need to release... why we are releasing it


answers:

<1>

The answer is YES.

The runtime connects the objects to IBOutlet using [setValue:ForKey:]. This function will find the private instance variables, retain the target and set it to the instance variable. Please visit here iOS Developer Library to know more.

I highly recommend you to read the article because many iOS framework accesses properties by Key-Value compliance ([setValue:ForKey:] or [valueForKey:]), instead of directly calling getters/setters/instance variables.

<2>

Answer is YES...

i was confused about that too, but try this:

open a xib file

onen assistant editor window and get the .h file code near your XIB IB file

chose an object in IB file (an object with no reference to any var)

ctrl click on it and chose: "new reference outlet" button

drag the line to your .h code file in the @interface{ } section

give a name to your new var ("aaa")

(note that no property "aaa" is created)

now Xcode has done all the magic for you, and...

in .m file you can find, in dealloc method:

- (void) dealloc {   
    [aaa release];
    [super dealloc];
}

so... if apple release it, it seems that the default IBOutlet vars loaded via XIB file are retained...


有关的文档是:

https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#//apple_ref/doc/uid/10000051i-CH4-SW35


英文不好,回头再好好看

目前对于这些问题的做法:

1.没有属性,直接release

2.属性的话 self.xxx=nil


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值