# 235-Taking iPad Apps for Mac to the Next Level
# Refinements for Mac
# Menu Bar
- UIKeyCommand
- UICommand
- UIMenu
- UIMenuBuilder
# Context Menus
- UIContextMenuInteraction
- UIAction
- UICommad
# Sidebars
- UISplitViewController
- minimumPrimaryColumnWidth
- maximumPrimaryColumnWidth
- primaryBackgroundStyle
- UITableView Style
- UITableViewStyle.grouped
- UITableviewStyle.insetGrouped
# Hover
UIHoverGestureRecognizer
# Mac Toolbars(AppKit)
- NSToolbar
- UIWindowScene.titlebar.toolbar
# Touch Bar(AppKit)
- NSTouchBar
- UIResponder.touchBar
- UIViewController.childViewControllerForTouchBar
- UIViewController.setNeedsTouchBarUpdate
# Demo
# Tool Bar
# Menu Bar
override func buildMenu(with builder: UIMenuBuilder) {
guard builder.system == .main else { return }
let logoutCommand = UIKeyCommand(title: "Sign Out",
action: #selector(AppDelegate.logout),
input: "L",
modifierFlags: [.command, .alternate])
let logoutMenu = UIMenu(title: "",
identifier: UIMenu.Identifier("com.xxx.logout"),
options: .displayInline,
children: [logoutCommand])
builder.insertSibling(logoutMenu, beforeMenu: UIMenu.Identifier.quit)
builder.remove(menu: UIMenu.Identifier.format)
}
override func validate(_ command: UICommand) {
if command.title == "Sign Out" {
command.attributes = isLogined ? [] : [.disabled]
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Adding Menus and Shortcuts to the Menu Bar and User Interface (opens new window)
# Application Lifecycle
On macOS, keep all mac catalyst apps foreground and active almost all the time.
Only enter the foreground inactive and background states during app termination and background launches.
When user initiate app termination(⌘Q), the state change notifications will take you from foreground active through foreground inactive to the background.
In background, the app will immediately appear as no longer running, but behind the scenes, we give background tasks a chance to finish.
If the user tries to launch the app while it is still backgrounded, we simply return your app to the foreground active state.
iOS has quite a few APIs that allow you to opt into some form of background launch for your app.
- Background URL sessions
- Silent push notifications
- Notification actions
- BackgroundTasks
Mac catalyst apps are rarely suspended on macOS. It is always terminated immediately even if no memory pressure exists.
# Distribution
# Notarized App
Signed by Developer ID