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.
精彩评论