官术网_书友最值得收藏!

Using and misusing manual reference counting

Now, let's take a look at how we can use and abuse those mechanics, and the kinds of errors that we can litter our code with when using manual reference counting:

- (void) doSomething {
NSString *aString = [[NSString alloc] init];
// calling alloc returns an object with a retain count of 1

// do something with the string

// We're done with the string, call release
[aString release];
}

The preceding is a very simplistic example; many times, you'll pass your objects around, and will need to keep track of when to retain or release your objects. Let's go over some of the issues that you can encounter if you're not careful with your retain and release calls.

主站蜘蛛池模板: 西盟| 屯门区| 禹城市| 长葛市| 务川| 富阳市| 柳州市| 西城区| 襄垣县| 兴隆县| 柯坪县| 湾仔区| 喀什市| 靖边县| 新宁县| 南通市| 平谷区| 大同县| 门头沟区| 会理县| 广元市| 浦城县| 沿河| 绩溪县| 柘城县| 台前县| 灵台县| 湄潭县| 阳曲县| 保康县| 高密市| 尼勒克县| 漳平市| 乐至县| 二连浩特市| 金坛市| 荥经县| 桦南县| 天镇县| 河南省| 逊克县|