开发者

what is garbage collected environment in iPhone?

开发者 https://www.devze.com 2023-01-08 06:54 出处:网络
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 (alloca

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

精彩评论

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