views:

32

answers:

1

Hi all,

I have a class wich is initialized like this.

// myclass.h
@property(nonatomic,retain) NSMutableArray *daysOfWeek; // this is in .h file

// myclass.m
@synthesize daysOfWeek;

-(id)init {
            if(self=[super init]) {
                    // initialize days of week
                    self.daysOfWeek = [NSMutableArray arrayWithCapacity:0];
            }
            return self;
    }

however later during application lifecycle, seems that daysOfWeek get freed. If I add retain in init method:

self.daysOfWeek = [[NSMutableArray arrayWithCapacity:0] retain];

then everything works as expected, and I can add and retrieve object from daysOfWeek. I tought that synthesize would retain the daysOfWeek, what am I missing here ?

thanks

+3  A: 
The problem lies somewhere else. Your original `init` is fine.
swegi
yes, the problem was in wrong dealloc method implementation. This question doesn't need any answer and doesn't add any real value to the web site, and unfortunately I cannot mark as delete.
Leonardo