• 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: NSTableCellView subclass layout from independent nib
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableCellView subclass layout from independent nib


  • Subject: Re: NSTableCellView subclass layout from independent nib
  • From: Seth Willits <email@hidden>
  • Date: Wed, 07 Mar 2012 23:02:18 -0800

On Mar 6, 2012, at 6:03 PM, Seth Willits wrote:

> Another possible solution is to use a class method on the cell view class which does loading from a nib. That method would then have some TableCellViewNibLoader class be File's Owner when loading the nib, and then the view inside the nib can actually be the table cell view instance which gets returned by the method. Possible, but also annoying.

<Note: Of course this email is resent now 2-days later than I wrote it… this mailing list isn't workin' too well at the moment :p >

Actually a separate class isn't needed. I had thought about it, thought it wasn't going to work, and now I realize it will work: You can just load the nib with no owner and scan the top level objects and find an instance of the cell view's class.


@implementation NSTableCellView (AraeliumAdditions)

+ (id)tableCellViewWithNibNamed:(NSString *)nibName;
{
    NSView * view = nil;
    NSArray * topLevelObjects = nil;
    NSNib * nib = [[[NSNib alloc] initWithNibNamed:nibName bundle:nil] autorelease];
    if (!nib || ![nib instantiateNibWithOwner:nil topLevelObjects:&topLevelObjects]) {
        return nil;
    }

    for (id obj in topLevelObjects) {
        if ([obj isKindOfClass:[self class]]) {
            view = obj;
            break;
        }
    }

    return view;
}

@end



So, other than that this is different of any other nib loading I know of, it's useful and convenient.


--
Seth Willits




--
Seth Willits



_______________________________________________

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: 
 >NSTableCellView subclass layout from independent nib (From: Seth Willits <email@hidden>)

  • Prev by Date: Re: Finding object array index when iterating through array
  • Next by Date: Re: Finding object array index when iterating through array
  • Previous by thread: NSTableCellView subclass layout from independent nib
  • Next by thread: Problem with refreshing NSMenuItems
  • Index(es):
    • Date
    • Thread