Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8452543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:31:38+00:00 2026-06-10T11:31:38+00:00

Originally I was populating my NSTableView via an outlet and had set the dataSource

  • 0

Originally I was populating my NSTableView via an outlet and had set the dataSource of the table to my controller class. I’m trying to switch to using an NSArrayController so I can enable sorting by column in my app.

In IB, I’ve added an Array Controller object. I have the Sort Descriptors binding connected to Shared User Defaults Controller so that the sorted column can be persisted between launches of my app. I have each column of my table bound to the Array Controller, the controller key is set to ‘arrangedObjects’ and the Model Key Path is set to the name of the field that should be rendered.

My data is coming from Core Data, and the entity I am trying to display has a relationship to another entity. An attribute on the 2nd entity needs to be displayed as the value for one of the table columns. Anyone have any thoughts/suggestions for me on what I’m missing here?

MainWindowController.h

#import <Cocoa/Cocoa.h>
#import "Notification.h"

@class AppDelegate;

@interface MainWindowController : NSWindowController <NSTableViewDataSource, NSTableViewDelegate> {
    AppDelegate <NSApplicationDelegate> *appDelegate;
}

//@property NSMutableArray *userNotifications;

@property (weak) IBOutlet NSTableView *notificationsTable;
@property (weak) IBOutlet NSArrayController *notificationsController;

@end

MainWindowController.m

#import "AppDelegate.h"
#import "MainWindowController.h"
#import "Utils.h"

@implementation MainWindowController

//@synthesize userNotifications;

@synthesize notificationsTable;
@synthesize notificationsController;

- (void) doubleClick:(id)sender
{
    NSInteger row = [notificationsTable clickedRow];

//  Notification *clickedNotification = [userNotifications objectAtIndex:row];
//  Notification *clickedNotification = 

//  [appDelegate redirectToBrowser:clickedNotification];
}

- (id) initWithWindowNibName:(NSString *)windowNibName
{
    self = [super initWithWindowNibName:windowNibName];
    if (self) {
//      userNotifications = [[NSMutableArray alloc] init];
        appDelegate = (AppDelegate *) [[NSApplication sharedApplication] delegate];
        [notificationsController setManagedObjectContext:[appDelegate managedObjectContext]];
        [notificationsController setEntityName:@"Notification"];
        [notificationsController setAutomaticallyPreparesContent:YES];

        [notificationsController fetch:self];
        [notificationsTable reloadData];
    }
    return self;
}

- (void)windowDidLoad
{
    [super windowDidLoad];

    // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.

    [notificationsTable reloadData];
}

- (void)awakeFromNib
{
    [notificationsTable setTarget:self];
    [notificationsTable setDoubleAction:@selector(doubleClick:)];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:31:40+00:00Added an answer on June 10, 2026 at 11:31 am

    There are two solutions to this issue:

    1. Add an App Delegate object to IB by adding a new object and setting the class to AppDelegate.
    2. Assign the App Delegate as an instance variable appDelegate of the controller rendering your window by adding the below code to your .h and .m files:

    Controller.h

    @class AppDelegate;
    
    @interface Controller : NSWindowController {
        AppDelegate <NSApplicationDelegate> *appDelegate;
    }
    

    Controller.m

    #import "AppDelegate.h"
    
    - (id) initWithWindowNibName:(NSString *)windowNibName
    {
        self = [super initWithWindowNibName:windowNibName];
        if (self) {
            appDelegate = (AppDelegate *) [[NSApplication sharedApplication] delegate];
        }
        return self;
    }
    

    In either case, you’ll need to add a new binding for the Array Controller. Navigate to the Binding pane in the Inspector and set the Managed Object Context (under Parameters) to Bind to (1) the App Delegate or (2) the File’s Owner, then set the Model Key Path to (1) self.managedObjectContext or (2) self.appDelegate.managedObjectContext

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a schema which was originally set up with MyISAM. I had relationships
Originally I had a design problem where I needed five subclasses of a superclass,
Originally I had two tables in my DB, [Property] and [Employee]. Each employee can
I originally setup some conditions using CGRectIntersectsRect for some collision detection which worked fine.
Originally i wanted to know whether ToList allocates more memory than using the constructor
I originally stored an objects origin and orientation in 3D space using 3 vectors
I'm using Visual Studio 2010. I have a class with the following constructor: CVideoAnnotation::CVideoAnnotation(std::string
Originally, I had basically written an essay with a question at the end, so
I have a standard select box which I'm populating using jquery by appending options,
I've built a web app which has a paste button for populating a table.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.