Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

spilakalb

macrumors member
Original poster
Sep 23, 2012
40
0
Can we use NSGarbageCollector class for memoer management in iPhone apps? Or is it only for Mac Programming?
 

MattInOz

macrumors 68030
Jan 19, 2006
2,760
0
Sydney
Can we use NSGarbageCollector class for memoer management in iPhone apps? Or is it only for Mac Programming?

Nope it's not in iOS and is never likely to be. It's deprecated on OS X as well.
Use ARC, let Apple's/LLVM's smartest engineers do your Memory Management.
 

Duncan C

macrumors 6502a
Jan 21, 2008
853
0
Northern Virginia
Can we use NSGarbageCollector class for memoer management in iPhone apps? Or is it only for Mac Programming?

As the other poster says, you can't. It is/was Mac OS only. (Thank god).

The garbage collector was a failed experiment. It was too slow for real-world development. It would cause UI "stutters" if the program ran the garbage collector during a critical user activity like drawing a free-form line on the screen.)

ARC is lightning fast and offers many of the same ease-of-use benefits.

About the only thing ARC doesn't handle that the garbage collector did handle is avoiding retain cycles. (If object A has a strong reference to object B, and object B also has a strong reference to object A, they'll never get released unless you clear one of the references. In the garbage collector, objects had to be be referenced by a known location in your program or they would be released, so it would automatically free object A and object B unless you had another strong reference to them somewhere.)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.