• 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: Reserved method prefixes in Cocoa. Is there a reference list?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reserved method prefixes in Cocoa. Is there a reference list?


  • Subject: Re: Reserved method prefixes in Cocoa. Is there a reference list?
  • From: Jens Alfke <email@hidden>
  • Date: Wed, 29 May 2013 11:28:32 -0700

On May 29, 2013, at 10:37 AM, Alex Zavatone <email@hidden> wrote:

> I'm aware that certain prefixes like "set" are bad news to use to start method names for obvious reasons, but with the caffeine levels in my brain cell running low, I'm at a loss to recall some of the others (is return verboten?).  Is there a list of reserved method prefix strings that you simply shouldn't use to start your methods?

There aren’t any forbidden prefixes that I know of, but there are ones that should be used only for particular purposes, because the compiler and/or runtime will make assumptions about them when they see that prefix.

It’s fine to have a method -setFoo:, it’s just that it will be interpreted as a setter for a property “foo”. Which is usually what you meant anyway.

ARC makes assumptions about special refcounting behavior of methods named “copy” or “mutableCopy” or that start with “init” or “alloc” or “new” — all of these are assumed to return an object reference that needs to be released by the caller. There might be others but those are all I can remember; the ARC docs may have a complete list.

—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: Reserved method prefixes in Cocoa. Is there a reference list?
      • From: Alex Zavatone <email@hidden>
    • Re: Reserved method prefixes in Cocoa. Is there a reference list?
      • From: Kyle Sluder <email@hidden>
References: 
 >Reserved method prefixes in Cocoa. Is there a reference list? (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Reserved method prefixes in Cocoa. Is there a reference list?
  • Next by Date: Re: Reserved method prefixes in Cocoa. Is there a reference list?
  • Previous by thread: Reserved method prefixes in Cocoa. Is there a reference list?
  • Next by thread: Re: Reserved method prefixes in Cocoa. Is there a reference list?
  • Index(es):
    • Date
    • Thread