• 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: dynamic binding in initializers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dynamic binding in initializers


  • Subject: Re: dynamic binding in initializers
  • From: Roland King <email@hidden>
  • Date: Thu, 24 Feb 2011 23:21:56 +0800

On 24-Feb-2011, at 11:02 PM, Dave Zarzycki wrote:

> Roland,
>
> Check this out:
>
> 	http://cocoawithlove.com/2008/03/cocoa-application-startup.html
>
> The code should arguably live in a +initialize method.
>
> davez

it can't - it's per-instance initialization.

Were there one designated initializer for a UIView, I'd put my initialization code in there, knowing that everything would end up going through it. However UIView's (and possibly other classes) don't have a designated initializer, they can be called with initWithFrame: or initWithCoder: depending on whether they were initialized in code or unpacked from a NIB, hence I want to put my per-instance initialization code in one place and call it from both of those. My reuse of the name 'internalInit' for the method I used for that purpose blew me up when I inherited from one of my own subclasses which used the same pattern.

I was hunting through the documentation to find a way of calling [ <this class you are actually in right now> someMethod ] so that I could name the method internalInit and be sure when I call it, I get mine, and if the superclass has its own it's going to call later, that will happen at that point. Nothing found however, seems a bit non-objective-C'ish. It seems if I have a method I really don't want to be dynamic, I should call it a class-specific name (which I just did, my internalInit is now internalInit_MyClass, ugly though)_______________________________________________

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: dynamic binding in initializers
      • From: Andy Lee <email@hidden>
    • Re: dynamic binding in initializers
      • From: Ken Thomases <email@hidden>
References: 
 >dynamic binding in initializers (From: Roland King <email@hidden>)
 >Re: dynamic binding in initializers (From: Dave Zarzycki <email@hidden>)

  • Prev by Date: Using asynchronous APIs with NSOperation
  • Next by Date: Re: Help Mixing Objective-C & Objective-C++
  • Previous by thread: Re: dynamic binding in initializers
  • Next by thread: Re: dynamic binding in initializers
  • Index(es):
    • Date
    • Thread