• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Objective-C Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Objective-C Question
      • From: Dave <email@hidden>
References: 
 >Objective-C Question (From: Dave <email@hidden>)
 >Re: Objective-C Question (From: Mike Abdullah <email@hidden>)
 >Re: Objective-C Question (From: Dave <email@hidden>)
 >Re: Objective-C Question (From: John McCall <email@hidden>)
 >Re: Objective-C Question (From: Dave <email@hidden>)
 >Re: Objective-C Question (From: John McCall <email@hidden>)
 >Re: Objective-C Question (From: Dave <email@hidden>)
 >Re: Objective-C Question (From: John McCall <email@hidden>)

  • Prev by Date: Re: Another Gnarly Objective-C Question!
  • Next by Date: Re: Objective-C Question
  • Previous by thread: Re: Objective-C Question
  • Next by thread: Re: Objective-C Question
  • Index(es):
    • Date
    • Thread