tags:

views:

43

answers:

2

Hi, everyone,

I want to ask some question about the iPhone or objective C. What is 'garbage collected environment'? Thank you very much.

+1  A: 

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.

Noah Witherspoon
thank you for your reply. And in the iPhone, is it use the view controller to handle a part or all the memory management?
Questions
+2  A: 

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.

esqew