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

chhoda

macrumors 6502
Original poster
Oct 25, 2008
285
1
hi all,

i have an nsarray @propery(nonatomic, retain) in a class MyClass

i do self.array = [MyAnotherclass getArray]; {static analyser points a memory leak here}


in the getArray function of another class I allocate NSArray

now the question is should i autorelease NSArray inside getArray function ?

if yes, should I also do a release in dealloc of MyClass like [self.array release]; {confusion because, i am not allocating in MyClass ! }
 
hi all,

i have an nsarray @propery(nonatomic, retain) in a class MyClass

i do self.array = [MyAnotherclass getArray]; {static analyser points a memory leak here}


in the getArray function of another class I allocate NSArray

now the question is should i autorelease NSArray inside getArray function ?

if yes, should I also do a release in dealloc of MyClass like [self.array release]; {confusion because, i am not allocating in MyClass ! }

I assume this is a class method:
Code:
[MyAnotherclass getArray]

If so, you should return an autoreleased array in getArray:

As your property is of the retain type, you should also release it in dealloc. But be sure to check if it is NULL (in case it was never set), or better, instantiate it in init:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.