should release or not? (basic memory management

Hi everyone.
I still have some doubts of should I release or not? and the most
important reaons why should I or why shouldn't I do it. Any answer
would be very appreciated.

Consider this:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *rawArray = [defaults objectForKey:@"lastArray"];
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
for(int i= 0; i< [rawArray count]; i++){
NSDictionary *dic = [rawArray objectAtIndex:i];
Mail *mail = [[Mail alloc] initWithDictionary:dic];
[tempArray addObject:mail];
[mail release];
theArray = tempArray;

Here theArray is a property:

@property (nonatomic, retain) NSArray *theArray;

So my doubts are:
Since is initialized by a class method , "defaults" must not be
released -> correct?
rawArray should be released? ([rawArray release] ?) I think the answer
is no but why?
dic should be released? ([dic release]?) I don't know...
tempArray should be released? I think the answer is: it depends.
Since theArray is retain I could do

self.theArray = tempArray;
[tempArray release];


theArray = tempArray;

so, what is the difference between using self and assigning tempArray
to theArray directly? (specifically in this case what is the
difference (in terms of retain count)?)
And what would happen with the retaincount of another object that was
theArray before tempArray assignation? (in case of doing theArray =

Thanks in advance.

Cocoa-dev mailing list (Cocoa-dev@xxxxxxxxxxxxxxx)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)

Help/Unsubscribe/Update your Subscription:

This email sent to maillists@xxxxxxxxx