Convenience Methods
Convenience Methods
- Subject: Convenience Methods
- From: Tim Davis <email@hidden>
- Date: Tue, 25 Sep 2007 21:31:01 -0400
2 quick questions for the guru's here.
1) I've added a convenience method to a class of mine so that it
minimizes the init/retains needed to create one just to slap into an
array. My question is, in the method should I be returning an object
of type (id) or an object that is the type of the class I'm
returning? Example:
+ (id)repoWithName:(NSString *)name OfType:(SVNDatabases)type AtPath:
(NSString *)path
{
id newInstance = [[[self class] alloc] init];
[newInstance setName: name];
[newInstance setType: type];
[newInstance setPath: path];
[newInstance loadUsers];
return [newInstance autorelease];
}
2) Using this method the object is autoreleased at some later point.
If I add this to an array/dictionary etc....does the dictionary
automaticly retain an instance or will it still disappear later?
Example:
[repositories setObject: [SVNRepository repoWithName: repoName
OfType: SVNFSFS AtPath: repoPath] forKey: repoName];
Thanks.
------------------
Dawn's cold passion filters through the trees
In darkness I showed you ecstacy
In darkness I took you from this world
Light shall never fall upon your face again
From spring I've waited for this winter's reap
I've watched you pass autumn's twilight yearning
Now with dawn I bring you eternal sleep
And silence all forever mourning...
_______________________________________________
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