Thu Rules of Cocoa Memory Management

When you create an object using [b]new, alloc, or copy[/b], the object has a retain count of 1. You are responsible for sending the object a release or autorelease message when
you're done with it. That way, it gets cleaned up when its useful life is over.

When you get hold of an object [b]via any other mechanism[/b], assume it has a retain count of 1 and that[b] it has already been autoreleased[/b]. You don't need to do any further
work to make sure it gets cleaned up. If you're going to hang on to the object for any
length of time, retain it and make sure to release it when you're done.

If you retain an object, you need to (eventually) release or autorelease it. [b]Balance
these retains and releases.[/b]

That's it -- just three rules.

From: <<Learn Objective-C on the mac>>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值