2 Questions about the project "With and Without bindings"
2 Questions about the project "With and Without bindings"
- Subject: 2 Questions about the project "With and Without bindings"
- From: Michael de Haan <email@hidden>
- Date: Fri, 23 Oct 2009 14:19:50 -0700
I am going through mmalc's excellent bindings pages...and learning a
lot.
But, may I ask 2 questions related to this, that I could not find in
the archives.
1)
When adding a bookmark, the bookmark object is initialized thus:
- init
{
if (self = [super init])
{
title = @"new title";
self.creationDate = [NSDate date];
}
return self;
}
**property declarations for title and creation date are @property
(copy) NSString *title // and NSDate * creationDate respectively**
Back in the calling method, creationDate is again called:
Bookmark *newBookmark = [[Bookmark alloc] init];
[newBookmark setCreationDate:[NSDate date]];
Is the reason that the date created in the initializer is an
autoreleased object, and thus the method adding the bookmark needs
it's own "owned" copy? Now I **thought** I understood this, but
"title" in the init method is directly assigned to it's ivar, and also
handed back to the calling method, without any further
intervention.......or should I read memory management again!!! :-)
2)
There is a lot of discussion about the fact that dealloc is not
necessarily called each time an object is disposed of. The rules of
memory management would seem to indicate that in the case of
initialization of doc.m:
- (id)init
{
self = [super init];
if (self)
{
collection = [[NSMutableArray alloc] init];
}
return self;
}
"collection" needs to be released. [ collection holds all the
bookmarks].
Now, there is no dealloc method called in this project's doc.m
So, my question is when is it appropriate to **omit** the dealloc
entirely?
Thank you as always.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden