• 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: Use Subclass in Interface Builder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use Subclass in Interface Builder


  • Subject: Re: Use Subclass in Interface Builder
  • From: Andy Lee <email@hidden>
  • Date: Wed, 05 Oct 2011 02:31:24 -0400

See "The Object Loading Process":

<http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#//apple_ref/doc/uid/10000051i-CH4-SW19>
> a. Standard Interface Builder objects (and custom subclasses of those objects) receive an initWithCoder: message.
[...]
> b. Custom views in Mac OS X receive an initWithFrame: message.

Your Method 1 corresponds to the "a" case. Your Method 2 corresponds to the "b" case.

--Andy


On Oct 5, 2011, at 1:32 AM, Dong Feng wrote:

> I have a subclass of NSOpenGLView which named POpenGLView. I tried two ways
> to use it in IB:
>
> Method 1:
> To create an OpenGL view in IB directly, and set its class type
> "POpenGLView".
>
> Method 2:
> To create a NSView in IB, and set its class type "POpenGLView".
>
> The most significant difference between the two ways is
>  - in Method 2, initWithFrame: is invoked.
>  - in Method 1, initWithCoder: is invoked.
>
> I checked Apple examples and found this one:
> http://developer.apple.com/library/mac/#samplecode/GLEssentials/Listings/main_m.html#//apple_ref/doc/uid/DTS40010104-main_m-DontLinkElementID_31
>
> Apple's example takes Method 2 and relies on the behavior of invoking
> initWithFrame: .
>
> What's the rule of IB/XIB regarding picking instantiate method?
>
> Thanks,
> Dong
_______________________________________________

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: Use Subclass in Interface Builder
      • From: Dong Feng <email@hidden>
References: 
 >Use Subclass in Interface Builder (From: Dong Feng <email@hidden>)

  • Prev by Date: Use Subclass in Interface Builder
  • Next by Date: Re: Use Subclass in Interface Builder
  • Previous by thread: Use Subclass in Interface Builder
  • Next by thread: Re: Use Subclass in Interface Builder
  • Index(es):
    • Date
    • Thread