0

Pretty simple idea here, I want to show all the NSWindows in an app. The idea being that there are two windows in the app, one his hidden the other is vissable. I want to show all the windows in the app and then hide one. I can hide the window I want to hide but I cant show the windows because I am unable to obtain a reference to it. is there anyway of getting a list of all the nswindows in the app then iterating through it and hiding them or something similar, I can use [NSApp windows] however trying to use

NSArray *windowArray = [NSApp windows];
[windowArray[0] makeKeyAndOrderFront:self];
[NSApp activateIgnoringOtherApps:YES];

does not work, nor does:

NSArray *windowArray = [NSApp windows];
NSWindow *tempWindow = windowArray[0];
[tempWindow makeKeyAndOrderFront:self];
[NSApp activateIgnoringOtherApps:YES];

any suggestions?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Jobalisk
  • 728
  • 1
  • 6
  • 17
  • It depends on whether you have xib files or window controllerers + view controllers to house windows. It is also unclear whether or not you have multiple xib files or storyboards. – El Tomato Dec 08 '16 at 01:36
  • its using a single nib file (this being xcode 2.5) with two nswindows in it – Jobalisk Dec 08 '16 at 02:28
  • I only suppose that windowArray really contains references to all existing windows in your xib file. Then shouldn't it be something like for (NSWindow *win in windowArray) { [win setIsVisible = YES]; } ? I won't test it myself since I no longer write Objective-C. – El Tomato Dec 08 '16 at 03:14
  • How do you hide the window? – Willeke Dec 08 '16 at 15:04
  • [menuWindow OrderOut:self] – Jobalisk Dec 08 '16 at 20:36

1 Answers1

0

Well in hindsight I've been a bit stupid. I had two seep rate controller objects each running one window. One was hardly doing anything as the view inside it was being handled by a different object so I just removed that one and made the first controller object take care of both windows. Problem solved.

Jobalisk
  • 728
  • 1
  • 6
  • 17