Re: Objective-C Question
Re: Objective-C Question
- Subject: Re: Objective-C Question
- From: Jens Alfke <email@hidden>
- Date: Tue, 12 Mar 2013 11:50:16 -0700
On Mar 12, 2013, at 9:44 AM, John McCall <email@hidden> wrote:
> However, that wouldn't be an idiomatic implementation. The usual expectation is that allocating methods, like +new methods, construct an object *of type self* (at least).
Are you just quibbling about the prefix “new-“? The specific method +new is expected to create a new instance of the receiving class, yes. There may be a convention (I can’t remember?) that class methods prefixed “new-” are intended to do the same.
However, it’s hardly unusual to have a class method that instantiates and returns some other kind of object. Dave’s use case of a dictionary that describes metadata about the class seems reasonable.
> This is why I was talking about instance methods and fields: because, generally, people introduce new classes because they expect to create instances of them, and [[self superclass] newDict] bypasses that in a way that might not be obvious.
I don’t see the problem here. Presumably the class is going to be instantiated at some point, but the code Dave is working with is operating on metadata about the class, so only class methods are involved in it.
—Jens
_______________________________________________
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