42893

Pass an NSMutableArray to a NSWindowController

Question:

So I am creating a NSWindowController like so:

if ( summaryWindow ) { [summaryWindow release]; } // end if summaryWindow = [[SummaryWindowController alloc] init];

I am then passing this object an array that I will be using for a NSTableView

[ summaryWindow setGlobalStatusArray:globalStatusArray];

Once that object is created, I realize I have don't know how to do something fundamental which is to link the newly created object actions and outlets. If I create a object in the xib, and link up the methods, I can run an action but I don't have access to the array because the xib created a separate instance of the NSWindowController, so how would one programmatically create the NSWindowController but also pass an array to it.

Answer1:

You just have to initialize the windowcontroller properly. [[SummaryWindowController alloc] init]; just creates an empty window controller that doesn't know its window an so on. You can load it with its xib file. Do it like this:

summaryWindow = [[SummaryWindowController alloc] initWithWindowNibName:@"YourWindowNIB"];

Answer2:

So I just ended up doing this via NSNotifications, and passing the Information via the userInfo.

// Register for notifications on Global Status Array updates [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadTableBuffer:) name:StatusUpdateNotification object:nil];

Like so:

- (void) reloadTableBuffer:(NSNotification *) notification { if(debugEnabled)NSLog(@"DEBUG: Was Told to Reload Table Buffer..."); NSDictionary *globalStatusUpdate = [notification userInfo];

Recommend

  • If a UITableViewCell has multiple buttons, where is the best place to handle touch events
  • Use SegmentController to Make TableView Disappear and UIContainerView Appear
  • UIView Subclass with a delegate using NIB
  • How do I set my nib File's Owner to an object in another nib file?
  • How to change splash screen in portable xamarin ios project?
  • Subclassing UICollectionViewCell and initialising from xib
  • Best approach for UITableViewCell with both a left and right label
  • Modifying files nested in tar archive
  • how to store data in database(sqlite)
  • C++ Pointer Arrays
  • Pythons argparse default value doesn't work
  • Fully customized Python Help Usage
  • sweetalert2 inputoptions from file in select example
  • Switch to popup in python using selenium
  • Bootstrap (v3.3.4) glyphicons not displayed in IE when refresh page (F5)
  • Updating both a ConcurrentHashMap and an AtomicInteger safely
  • Implementing “partial void” in VB
  • Sending HTML Form Data to Spring REST Web Service
  • Replace value with Factor in r data.table
  • swift auto completion not working in Xcode6-Beta
  • Finding past revisions of files in StarTeam w/ .NET SDK / C#
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Javascript Callbacks with Object constructor
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • what is the difference between the asp.net mvc application and asp.net web application
  • Weird JavaScript statement, what does it mean?
  • Apache 2.4 - remove | delete | uninstall
  • SVN: Merging two branches together
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • Cannot Parse HTML Data Using Android / JSOUP
  • Comma separated Values
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • Benchmarking RAM performance - UWP and C#
  • Error creating VM instance in Google Compute Engine
  • C# - Getting references of reference
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?