No. Don't do this. The class name might change at any time. Do what I suggested. Check something which is under your control.
--Kyle Sluder On Feb 26, 2013, at 10:59 PM, anni saini <anni_sa...@yahoo.com> wrote: > > I got the solution, just need to check for NSStatusBarWindow className as > follows: > if([awindow isVisible] && ![aWindow aboutWin] && ![aWindow loginWindow] && > ![[aWindow className] isEqual:@"NSStatusBarWindow"]) > > Thanks. > From: Kyle Sluder <k...@ksluder.com> > To: Anil Saini <anni_sa...@yahoo.com> > Cc: "cocoa-dev@lists.apple.com" <cocoa-dev@lists.apple.com> > Sent: Tuesday, 26 February 2013 9:35 PM > Subject: Re: Issue of NSStatusBar > > On Feb 26, 2013, at 9:16 AM, Anil Saini <anni_sa...@yahoo.com> wrote: > > > Hi, > > > > I was facing issue of NSStatusBar getting closed by the [window close]. > > > > In our application, we have used [NSStatusBar SystemStatusBar] to display > > menu. In a particular scenario, I need to close all the windows of my > > application except About and Login, so I wrote following function: > > - (void)closeIrrelevantWindows > > { > > NSSArray *allWindows = [NSApp windows]; > > > > for(NSWindow *aWindow in allWindows) > > { > > if([awindow isVisible] && ![aWindow aboutWin] && ![aWindow loginWindow]) > > [aWindow close]; > > } > > } > > > > This call some times closes my NSStatusItem as well. Can anybody tell me > > whats wrong with the above code? > > I checked NSStatusItem and NSStatusBar class reference both are derived > > from NSObject. > > In order to display anything, it needs to be placed in a window. Your code > above is correct in that it doesn't send -close to any status bar items, but > it *does* send -close to the invisible window that constrains them. That's > why they disappear. > > You'll probably want to do some more careful checking of the windows prior to > sending them -close. Perhaps check the class of their window controller or > their delegate. > > --Kyle Sluder > > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com