开发者

what is garbage collected environment in iPhone?

I want to ask some questio开发者_运维问答n about the iPhone or objective C. What is 'garbage collected environment'? Thank you very much.


Expanding on Mr. Witherspoon's answer, you must alloc (allocate) and release memory space for some objects in your code. To practice good memory management, anything you have an alloc for you must have a matching release. For example:

NSString *string = [[NSString alloc]initWithFormat:@"%@", something];
/* ... some code ... */
[string release];

As you can see, my string is allocated some memory space but I release it programmatically when I won't need it anymore.


Garbage collection is a feature of the Objective-C runtime on the Mac and is not yet available on the iPhone. There, it basically means that you don't have to worry as much about memory management and handling retain / release cycles.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜