• 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: Is it possible to define class from interface builder?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it possible to define class from interface builder?


  • Subject: Re: Is it possible to define class from interface builder?
  • From: email@hidden
  • Date: Thu, 15 Aug 2013 15:26:18 +0900


On 2013/08/15, at 15:08, Chris Hanson <email@hidden> wrote:

> On Aug 13, 2013, at 11:34 AM, Izak van Langevelde <email@hidden> wrote:
>
>> A user interface contains several instances of a specific form, which is easily created in Interface Builder.
>> Is there any way to derive a subclass of NSView from this form, so that it can be reused?
>
> A good way to do this is to create a xib that has an NSView with your form all laid out. Then use the Inspector to set File’s Owner’s class to NSViewController; File’s Owner will get a “view” outlet as a result of that. Then just connect that “view” outlet to your view.
>
> That will get you a reusable NSViewController you can instantiate using -[NSViewController initWithNibName:bundle:] any number of times in your application, and you can thus substitute its view into your app at any place you like.
>
> You could also create an NSView subclass, call it a “ViewControllerHostView,” that knows how to embed a view controller’s view within itself based on a User Defined Runtime Attribute you set up in Interface Builder.[1]
>
> That way your ViewControllerHostView can have a controllerNibName property that gets set when it’s instantiated at load time; it can then, when it’s actually being presented, also load the view controller from the named nib and embed its view within itself.
>
>  -- Chris
>
> [1] User Defined Runtime Attributes are values set in Interface Builder that then get set on your objects via KVC when a nib file is loaded. They work in OS X 10.6 and iOS 5

Wow.

That sounds like a *really* powerful workflow.
Are there any good example code downloads or tutorials that illustrate this well?


_______________________________________________

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


References: 
 >Is it possible to define class from interface builder? (From: Izak van Langevelde <email@hidden>)
 >Re: Is it possible to define class from interface builder? (From: Chris Hanson <email@hidden>)

  • Prev by Date: Re: Is it possible to define class from interface builder?
  • Next by Date: NSToolbar's setShowsBaselineSeparator
  • Previous by thread: Re: Is it possible to define class from interface builder?
  • Next by thread: "Stale" URL bookmarks?
  • Index(es):
    • Date
    • Thread