• 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: Namespace clash problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Namespace clash problem


  • Subject: Re: Namespace clash problem
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 13 Oct 2011 17:28:16 -0700

On Oct 13, 2011, at 4:29 PM, Graham Cox wrote:

> When I go into this warning, it further states it's using [NSProgressIndicator style] instead of my own declared method style which exists in many different objects (and which would be correct).

This only happens when calling -style on an untyped (id) pointer. Cast the pointer to your class and you won’t have a problem. Instead of
	[[array lastObject] style]
use
	[(MyClass*)[array lastObject] style]
This has the added advantage that, if you ever renamed or removed your -style method, the compiler would be able to warn you if you didn’t fix this call.

> (<RANT> why do Apple have to steal such obvious names when they know there is a namespace problem? This could easily have been named 'progressIndicatorStyle' and have much less chance of clashing with user code.

I would rather have shorter, clearer names in framework classes. The name-collision thing doesn’t happen to me often, and when it does I just use a typecast like above.

—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: Namespace clash problem
      • From: Graham Cox <email@hidden>
References: 
 >Namespace clash problem (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Best way to parse a time today?
  • Next by Date: Re: Namespace clash problem
  • Previous by thread: Namespace clash problem
  • Next by thread: Re: Namespace clash problem
  • Index(es):
    • Date
    • Thread