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

estupefactika

macrumors member
Original poster
Feb 16, 2009
47
0
Alcobendas (Madrid)
Hi, I have a doubt when I release objects, Have I to release NsDictionary, NsMutableDictionary, NsArray, NsMutableArray, NsNumber, etc when I create them with alloc?

Are there any classes like NSString that its not neccesary? thanks
 
Anything you use with alloc needs to be released. The reason your NSString does not have to have it is because you're using a convenience function that returns and autorelease object.
 
Basically if you use alloc, copy or mutableCopy to create the object or explicitly retain the object then it needs releasing. Objects that are otherwise obtained (eg arrayWithObjects: or stringWithFormat:) are autoreleased so do not need to be released (unless YOU retained them).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.