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 9134743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:43:02+00:00 2026-06-17T08:43:02+00:00

I’m writing an OSX app where a second window is opened to show results

  • 0

I’m writing an OSX app where a second window is opened to show results when the button on the first window is pushed. The window-2 start fine and shows what I want. But when I change inputs in window-1 and hit the action button again the window-2 doesn’t update the results.

here my questions:

  1. how does the content of window-2 update after input change in window-1
  2. how is window-2 closed and released (right now window-2 shows up with the same content before closed when action button is pushed again)

here is the code for the action button:

- (IBAction)pushRun:(id)sender {

    if (!rwc)
    {
        rwc = [[ResultWindowController alloc] init];

        [rwc setValueArray:[toDoItemArrayController arrangedObjects]];
        [rwc setNumberOfCalculations:[NSNumber numberWithInt:[_inputNumberOfCalculations intValue]]];
        [rwc calculateResults]; //starts method in 2nd-window controller for result calculation

    }

    [rwc showWindow:self]; 
}

It might be easy but I’m afraid to always create an other ResultWindowController instance.

Thanks in advance.
Joerg

here is the ResultWindowController.h:

#import <Cocoa/Cocoa.h>

@interface ResultWindowController : NSWindowController{

    NSArray *valueArray;
    NSMutableArray *resultArray;
    NSNumber *numberOfCalculations;
}

@property (nonatomic, retain, readwrite) NSArray *valueArray;
@property (retain) NSNumber *numberOfCalculations;
@property (nonatomic, retain, readwrite) NSMutableArray *resultArray;

-(void)calculateResults;

@end

and here the ResultWindowController.m

#import "ResultWindowController.h"
#import "ResultItem.h" //my result model

@implementation ResultWindowController
@synthesize valueArray, resultArray, numberOfCalculations;

- (id)init
{
    if(![super initWithWindowNibName:@"ResultWindow"])
    return nil;
    return self;
}

-(void)awakeFromNib
{

}

- (void)windowDidLoad
{
    [super windowDidLoad];
}

- (void)calculateResults
{
    //a lot of calculation code ...

    ResultItem *newResult = [[ResultItem alloc]init];

    [newResult setValue:[nameArray objectAtIndex:i] forKey:@"name"];
    [newResult setValue:[NSNumber numberWithDouble:avg] forKey:@"averageValue"];
    [newResult setValue:[NSNumber numberWithDouble:min] forKey:@"minValue"];
    [newResult setValue:[NSNumber numberWithDouble:max] forKey:@"maxValue"];
    [newResult setValue:dimensionRandomArray forKey:@"randomArray"];

    [resultArray addObject:newResult]; 

}

resultarray is the content source for an arraycontroller in the ResultWindowController.xib. The arraycontroller is bound to a table view which is supposed to show the array content. This is not updated the second time.

  • 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-17T08:43:02+00:00Added an answer on June 17, 2026 at 8:43 am

    I believe you must simply do the following:

    - (IBAction)pushRun:(id)sender {
    
        if (!rwc)
        {
            rwc = [[ResultWindowController alloc] init];
    
            [rwc setValueArray:[toDoItemArrayController arrangedObjects]];
            [rwc setNumberOfCalculations:[NSNumber numberWithInt:[_inputNumberOfCalculations intValue]]];
            [rwc calculateResults]; //starts method in 2nd-window controller for result calculation
    
        }
            [rwc setValueArray:[toDoItemArrayController arrangedObjects]];
            [rwc setNumberOfCalculations:[NSNumber numberWithInt:[_inputNumberOfCalculations intValue]]];
            [rwc calculateResults]; //starts method in 2nd-window controller for result 
        [rwc showWindow:self]; 
    }
    

    You were only changing values of ResultWindowController if it did not exist. You want to change values no matter what, just not start a new instance. So, as long as you don’t use [[alloc]init] you’re good.

    Hope that helps. If you need anything else, drop a comment.

    Edit

    To create a property for your tableView do the following:

    In .h

    #import <Cocoa/Cocoa.h>
    
    @interface ResultWindowController : NSWindowController{
    
        NSArray *valueArray;
        NSMutableArray *resultArray;
        NSNumber *numberOfCalculations;
    }
    
    @property (nonatomic, retain, readwrite) NSArray *valueArray;
    @property (retain) NSNumber *numberOfCalculations;
    @property (nonatomic, retain, readwrite) NSMutableArray *resultArray;
    @property (assign) NSTableView *yourTableView;   //Add this code
    -(void)calculateResults;
    
    @end
    

    and here the ResultWindowController.m

    #import "ResultWindowController.h"
    #import "ResultItem.h" //Your result model
    
    @implementation ResultWindowController
    @synthesize valueArray, resultArray, numberOfCalculations;
    @synthesize yourTableView;  //Add this code
    

    Then you should be able to call [yourTableView reloadData]

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I am writing an app with both english and french support. The app requests
I am writing an app for my school newspaper, which is run completely online
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Specifically, suppose I start with the string string =hello \'i am \' me And
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to show the soap response to UIWebview.. my soap response is, <p><img
I'm trying to select an H1 element which is the second-child in its group
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am using Paperclip to handle profile photo uploads in my app. They upload

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.