<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSApplicationDelegate/applicationShouldHandleReopen(_:hasVisibleWindows:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSApplicationDelegate(im)applicationShouldHandleReopen:hasVisibleWindows:"
  },
  "title" : "applicationShouldHandleReopen(_:hasVisibleWindows:)"
}
-->

# applicationShouldHandleReopen(_:hasVisibleWindows:)

Returns a Boolean value that indicates if the app responds to reopen AppleEvents.

```
@MainActor optional func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows: Bool) -> Bool
```

## Parameters

`sender`

The application object.

`hasVisibleWindows`

Indicates whether the `NSApplication` object found any visible windows in your application. You can use this value as an indication of whether the application would do anything if you return <doc://com.apple.documentation/documentation/Swift/true>.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if you want the application to perform its normal tasks or <doc://com.apple.documentation/documentation/Swift/false> if you want the application to do nothing.

## Discussion

These events are sent whenever the Finder reactivates an already running application because someone double-clicked it again or used the dock to activate it.

By default the Application Kit will handle this event by checking whether there are any visible `NSWindow` (not `NSPanel`) objects, and, if there are none, it goes through the standard untitled document creation (the same as it does if `theApplication` is launched without any document to open). For most document-based applications, an untitled document will be created.

The application delegate will also get a chance to respond to the normal untitled document delegate methods. If you implement this method in your application delegate, it will be called before any of the default behavior happens. If you return <doc://com.apple.documentation/documentation/Swift/true>, then `NSApplication` will proceed as normal. If you return <doc://com.apple.documentation/documentation/Swift/false>, then `NSApplication` will do nothing. So, you can either implement this method with a version that does nothing, and return <doc://com.apple.documentation/documentation/Swift/false> if you do not want anything to happen at all (not recommended), or you can implement this method, handle the event yourself in some custom way, and return <doc://com.apple.documentation/documentation/Swift/false>.

Miniaturized windows, windows in the Dock, are considered visible by this method, and cause `flag` to return <doc://com.apple.documentation/documentation/Swift/true>, despite the fact that miniaturized windows return <doc://com.apple.documentation/documentation/Swift/false> when sent an [`isVisible`](/documentation/AppKit/NSWindow/isVisible) message.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)