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

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.

主站蜘蛛池模板: 曲水县| 临城县| 银川市| 武陟县| 醴陵市| 章丘市| 睢宁县| 镇宁| 永平县| 安义县| 丹东市| 合作市| 尼木县| 桐城市| 松原市| 日喀则市| 大足县| 新巴尔虎左旗| 达日县| 海南省| 东海县| 靖远县| 文水县| 临颍县| 军事| 吉林省| 临桂县| 潞城市| 临沧市| 邢台市| 台江县| 南宫市| 大名县| 宣恩县| 宜州市| 虹口区| 敦煌市| 库伦旗| 玉山县| 太仓市| 武山县|