Personally, when I use a macOS application, I often use the tab key to switch from one text field to another. Meanwhile, I've been developing macOS applications for 10 years or so. Sometimes, if I press the tab key, my application won't switch from one text field to another. I wonder why that happens? I'm working on a new desktop application now. It's almost done. And pressing the tab key won't let me switch from one text field to another. Does anybody have any idea why? Thanks.
Post
Replies
Boosts
Views
Activity
Several years ago, I developed a status menu application in Objective-C. And I'm developing a new one in Swift. I have some lines of code in AppDelegate to show a status menu (NSMenu).And I see Command H in the status menu. If I press Command H, the application won't call showHome()class AppDelegate: NSObject, NSApplicationDelegate {
// MARK: - Variables
var statusItem = NSStatusItem()
// MARK: - IBOutlet
@IBOutlet weak var statusMenu: NSMenu!
func applicationWillFinishLaunching(_ notification: Notification) {
makeStatusMenu()
}
func makeStatusMenu() {
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
if let img = NSImage(named: "StatusMenuImage") {
statusItem.image = img.resize(w: 18.0, h: 18.0)
}
statusItem.menu = statusMenu
let showHomeMenuItem = NSMenuItem(title: "Show Home", action:#selector(showHome), keyEquivalent: "h")
statusMenu.addItem(showHomeMenuItem)
}
@objc func showHome() {
}
}What am I doing wrong?Thanks.
I have a Cocoa application in development that lets the user take a screenshot. The application uses the CGWindowListCreateImage function to take desktop screenshots. Under macOS 15, when I launch the application and let it take a desktop screenshot, System Preferences lauches itself and and adds my application to Security & Privacy > Screen Recording > Privacy. So my question is Do I need to add a privacy key to the Info list? If I check the Info list, I don't find any privacy key related to screen recording.Mucho thankos.
I have an IBOutlet-wired NSView object named displayView, where I add 3 to 4 NSImageView objects as subViews. Whenever the user resizes the application window, this displayView guy needs to be updated. When the user closes the application window with the red close button, the application hides it withNSApp.hide(nil). When the user clicks on the doc icon of the application, the application unhide the window. When it does, the application will remove all sub views likefor sub in displayView.subviews {
sub.removeFromSuperview()
}But the application leaks the memory a big time. If I repeat the sequence of hiding and unhiding the application window 5 to 6 times, its memory consumption can reach 500 MB. I know what to do, but my question is why the application keeps mounting its leak even though it removes its all sub views whenever the application is back to life from hiding itself and updates the displayView guy.Muchos thankos.
I have a Cocoa desktop application that allows the user to take desktop screenshots invovling not just the application itself but also other applications. Therefore, it has to use the CGWindowListCreateImage function. Inevitably, the user will be prompted for an alert message with screen recording privacy under macOS 10.15.The reviewer rejects this application because the application shows this alert message under macOS 10.15. I've asked the reviewer what screen recording privacy for, then? And he or she says that it's for producing a video. But there is nothing else other than the CGWindowListCreateImage function, which is inevitably the reason for screen recording privacy. And the same review tells me to use alternatives without naming one. To my knowledge, there is no alternative to CGWindowListCreateImage for taking a desktop screenshot involving other applications. Or is there?
I have a desktop application that allows the user to use it fully without limiations for a week. After one week, it will validate their in-app purchase status. I'll make a simple case. Let me suppose that the application allows them to draw a triangle. After the expiration, they can still draw a triangle. But it won't let them save it as an image to disk after expiration. For the past several months, many of my desktop applications have this free-for-1-week-with-IAP business style. And I never had a problem with reviewers in this regard. This time, I've been hit with the following rejection description.Guideline 4.2 - DesignWe found that your app provides a limited set of features and functionality to users and is therefore not appropriate for the App Store. Specifically, the app requires an in-app purchase after 1 week to continue use.Next StepsWe encourage you to review your app concept and evaluate whether you can incorporate additional features to enhance the user experience.First, I had no idea what the problem this reviewer is saying. I now suppose that he or she has rejected it because the application would be no use after one week. If I'm right, then so what!? I don't really have a problem if every app is treated in the same way. But if this app is rejected because the user will have no use without a purchase after one week, then many of them, if not all, subscription-based apps also have to go? I have asked the reviewer why I need to enterain the user further after one week of free trial. And he or she has ignored my question so far.So what do you think? Thanks.P.S. I see a lot of subscription-based desktop applications at Mac App Store. And I had one desktop application several months ago with a subscription IAP. The reviewer rejected it because it's not a news app and therefore the subscription IAP is not allowed, he or she said.
I have a button (Click me) at the top. And it's followed by some space and stacks of buttons that are horizontally laid out as follows.
import SwiftUI
struct ContentView: View {
		var body: some View {
				ZStack {
						VStack(spacing: 0.0) {
								Button("Click me", action: {
																				
								})
								Spacer()
										.frame(height: 20)
								
								HStack(spacing: 0.0) {
										ForEach((0...6), id: \.self) {
												Button("") {
														
												}
												.tag($0)
												.buttonStyle(BorderlessButtonStyle())
												.frame(width: 48, height: 48, alignment: .center)
												.background(RoundedRectangle(cornerRadius: 2)
																				.fill(Color.white)
																				.shadow(color: Color.black.opacity(0.4), radius: 2, x: 0, y: 0)
												)
										}
								}
								...
								...
								...
								HStack(spacing: 0.0) {
										ForEach((28...34), id: \.self) {
												Button("") {
														
												}
												.tag($0)
												.buttonStyle(BorderlessButtonStyle())
												.frame(width: 48, height: 48, alignment: .center)
												.background(RoundedRectangle(cornerRadius: 2)
																				.fill(Color.white)
																				.shadow(color: Color.black.opacity(0.4), radius: 2, x: 0, y: 0)
												)
										}
								}
								HStack(alignment: .top, spacing: 0.0) {
										ForEach((35...36), id: \.self) {
												Button("") {
														
												}
												.tag($0)
												.buttonStyle(BorderlessButtonStyle())
												.frame(width: 48, height: 48, alignment: .center)
												.background(RoundedRectangle(cornerRadius: 2)
																				.fill(Color.white)
																				.shadow(color: Color.black.opacity(0.4), radius: 2, x: 0, y: 0)
												)
										}
								}
								.frame(width: 336.0, height: 48.0, alignment: .leading)
						}
				}
		}
}
None of the buttons except the very top one has a title as you see above. And I want to set a title to each button and show or hide any of them when necessary. So is it possible for me to access any of the buttons with its tag and set its title and show or hide it? Thank you.
I want to create a drop-down menu with years like the following.
import SwiftUI
struct ContentView: View {
		@State var menuLabel = "2020"
		
		var body: some View {
				MenuButton(menuLabel) {
						Button("2020") {
								menuLabel = "2020"
						}
						Button("2021") {
								menuLabel = "2021"
						}
						Button("2022") {
								menuLabel = "2022"
						}
				}
				.frame(width: 68.0)
				.frame(maxWidth: .infinity, maxHeight: .infinity)
		}
}
But that's tedious. So if I would rather do it with ForEach.
import SwiftUI
struct ContentView: View {
		@State var menuLabel = "2020"
		
		var body: some View {
				MenuButton(menuLabel) {
						ForEach((2020...2030), id: \.self) {
								Button(String($0)) {
										menuLabel = String($0)
								}
						}
				}
				.frame(width: 68.0)
				.frame(maxWidth: .infinity, maxHeight: .infinity)
		}
}
And I will get an error unless I comment out
menuLabel = String($0)
It says
Contextual closure type '() -> Void' expects 0 arguments, but 1 was used in closure body I don't know what it means. So what does it mean, and how can I set the selection to the title of MenuButton, anyway? Thank you.
Let me suppose that I have a horizontal stack of six buttons like the following.
import SwiftUI
struct ContentView: View {
		var body: some View {
				ZStack {
						VStack {
								HStack(spacing: 0.0) {
										Button("1") {
												
										}
										.buttonStyle(BorderlessButtonStyle())
										.frame(width: 48, height: 48, alignment: .center)
										.background(
												RoundedRectangle(cornerRadius: 2)
														.fill(Color.white)
														.shadow(color: Color.black.opacity(0.4), radius: 2, x: 0, y: 0)
										)
										...
										...
										...
										Button("6") {
												
										}
										.buttonStyle(BorderlessButtonStyle())
										.frame(width: 48, height: 48, alignment: .center)
										.background(
												RoundedRectangle(cornerRadius: 2)
														.fill(Color.white)
														.shadow(color: Color.black.opacity(0.4), radius: 2, x: 0, y: 0)
										)
								}
						}
				}.frame(minWidth: 360, idealWidth: 360, maxWidth: 360, minHeight: 240, idealHeight: 240, maxHeight: 240, alignment: .center)
		}
}
In the scenario above, each button is a size of 48 points x 48 points. And I want to add a small number at the top-left corner of each button. ('Small number' means a smaller font size than the button text size.) In Cocoa, it would be like adding (addSubView) an NSTextField object to an NSButton object. In SwiftUI, how can I add a small number to each button? Thank you.
I have the following lines of code where I have several vertical stacks of horizontal stacks of buttons on top of a push button titled 'Click me.'
import SwiftUI
struct ContentView: View {
		@State private var eventPresented = false
		@State var fillColors: [Color] = Array(repeating: Color.white, count: 38)
		@State var buttonTitles: [String?] = Array(repeating: nil, count: 38)
		
		var body: some View {
				VStack {
						/* click me */
						VStack() {
								Button("Click me", action: {
										buttonTitles.removeAll()
										for i in 0..<38 {
												buttonTitles.append(String(i + 1))
										}
										fillColors.removeAll()
										for _ in 0..<2 {
												fillColors.append(Color.clear)
										}
										for _ in 0..<36 {
												fillColors.append(Color.white)
										}
								})
						}
						
						/* cal buttons */
						VStack(spacing: 0.0) {
								HStack(spacing: 0.0) {
										ForEach((0...6), id: \.self) {
												Button(buttonTitles[$0] ?? "") {
														eventPresented = true
												}
												.buttonStyle(BorderlessButtonStyle())
												.frame(width: 48, height: 48, alignment: .center)
												.background(RoundedRectangle(cornerRadius: 2)
																				.fill(fillColors[$0])
																				.shadow(color: Color.black.opacity(0.4), radius: 2, x: 0, y: 0)
												)
										}
								}
								...
								...
								...
								HStack(alignment: .top, spacing: 0.0) {
										ForEach((35...36), id: \.self) {
												Button(buttonTitles[$0] ?? "") {
														
												}
												.buttonStyle(BorderlessButtonStyle())
												.frame(width: 48, height: 48, alignment: .center)
												.background(RoundedRectangle(cornerRadius: 2)
																				.fill(fillColors[$0])
																				.shadow(color: Color.black.opacity(0.4), radius: 2, x: 0, y: 0)
												)
										}
								}
								.frame(width: 336.0, height: 48.0, alignment: .leading)
						}
				}
		}
}
If I click on 'Click me,' the application will label each button. My question is how I take the function out of this button. If I do something like the following as I used to doing in Cocoa and UIKit, I get an error. (I've created a function named 'makeButtons.')
import SwiftUI
struct ContentView: View {
		@State private var eventPresented = false
		@State var fillColors: [Color] = Array(repeating: Color.white, count: 38)
		@State var buttonTitles: [String?] = Array(repeating: nil, count: 38)
		
		var body: some View {
				makeButtons()
				
				/* cal buttons */
				VStack(spacing: 0.0) {
						HStack(spacing: 0.0) {
								ForEach((0...6), id: \.self) {
										Button(buttonTitles[$0] ?? "") {
												eventPresented = true
										}
										.buttonStyle(BorderlessButtonStyle())
										.frame(width: 48, height: 48, alignment: .center)
										.background(RoundedRectangle(cornerRadius: 2)
																		.fill(fillColors[$0])
																		.shadow(color: Color.black.opacity(0.4), radius: 2, x: 0, y: 0)
										)
								}
						}
						...
						...
						...
						HStack(alignment: .top, spacing: 0.0) {
								ForEach((35...36), id: \.self) {
										Button(buttonTitles[$0] ?? "") {
												
										}
										.buttonStyle(BorderlessButtonStyle())
										.frame(width: 48, height: 48, alignment: .center)
										.background(RoundedRectangle(cornerRadius: 2)
																		.fill(fillColors[$0])
																		.shadow(color: Color.black.opacity(0.4), radius: 2, x: 0, y: 0)
										)
								}
						}
						.frame(width: 336.0, height: 48.0, alignment: .leading)
				}.frame(minWidth: 370, idealWidth: 370, maxWidth: 370, minHeight: 420, idealHeight: 420, maxHeight: 420, alignment: .top)
		}
		
		func makeButtons() {
				buttonTitles.removeAll()
				for i in 0..<38 {
						buttonTitles.append(String(i + 1))
				}
				fillColors.removeAll()
				for _ in 0..<2 {
						fillColors.append(Color.clear)
				}
				for _ in 0..<36 {
						fillColors.append(Color.white)
				}
		}
}
Thank you.
I have two MenuButtons, equivalent to NSPopupButtons in Cocoa. One has a list of years, starting at 2020, and the other lists calendar months. So I have the following test code to see how the MenuButton button works.
import SwiftUI
struct ContentView: View {
		@State var yearSelection = 2020
		@State var monthSelection = 12
		@State var monthLiteral = "December"
		
		var body: some View {
				ZStack {
						VStack {
								Spacer()
										.frame(height: 8)
								HStack {
										Spacer()
												.frame(width: 16)
										MenuButton(String(yearSelection)) {
												ForEach((2020...2030), id: \.self) {
														year in
														Button(String(year)) {
																yearSelection = year
														}
												}
										}.frame(width: 68.0)
										
										MenuButton(monthLiteral) {
												ForEach((1...12), id: \.self) {
														month in
														let monStr = Calendar.current.monthSymbols[month - 1]
														Button(monStr) {
																monthSelection = month
																monthLiteral = monStr
														}
												}
										}.frame(width: 102.0)
										Spacer()
								}
								Spacer()
								Button("Select me") {
										yearSelection = 2024
								}
						}
				}.frame(minWidth: 370, idealWidth: 370, maxWidth: 370, minHeight: 200, idealHeight: 200, maxHeight: 200, alignment: .center)
		}
}
Initially being black, if I use the year menu button to select a year, its title color will turn light gray. If I touch the menu button with the mouse pointer, the title color will turn back black. If I click on the select me push button at the bottom to select a year, again, the title color will turn light gray. Is that how the menu button works? It's kind of a cheap Dutch doll. (No offense to Dutch people...). I think this stack overflow topic - https://stackoverflow.com/questions/65050365/issue-about-menu-title-under-macos-decreased-opacity is what I'm talking about. Or am I doing something wrong? Thank you.
I have several vertical stacks of six horizontal buttons. And I want to open a modal sheet based on the button they click on.
import SwiftUI
struct ContentView: View {
		@State private var eventPresented = false
		@State private var selectedEventIndex = 3
		
		@State var shadowColors: [Color] = Array(repeating: Color.clear, count: 38)
		@State var titleColors: [Color] = Array(repeating: Color.black, count: 38)
		@State var fillColors: [Color] = Array(repeating: Color.clear, count: 38)
		@State var buttonTitles: [String?] = Array(repeating: nil, count: 38)
		@State var eventNumbers: [String?] = Array(repeating: nil, count: 38)
		
		var body: some View {
				VStack {
						VStack(spacing: 0.0) {
								HStack(spacing: 0.0) {
										ForEach((0...6), id: \.self) {
												Button(buttonTitles[$0] ?? "") {
														eventPresented = true
														selectedEventIndex = 5 // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
												}
												.foregroundColor(titleColors[$0])
												.overlay(Text(eventNumbers[$0] ?? "").font(.footnote).foregroundColor(.blue).offset(x: -16, y: -16))
												.buttonStyle(BorderlessButtonStyle())
												.frame(width: 48, height: 48, alignment: .center)
												.background(RoundedRectangle(cornerRadius: 2)
																				.fill(fillColors[$0])
																				.shadow(color: shadowColors[$0], radius: 2, x: 0, y: 0)
												)
												.sheet(isPresented: $eventPresented) {
														EventView(eventVisible: self.$eventPresented, valueFromParent: self.$selectedEventIndex)
												}
										}
								}
								...
								...
								...
								HStack(alignment: .top, spacing: 0.0) {
										ForEach((35...36), id: \.self) {
												Button(buttonTitles[$0] ?? "") {
														eventPresented = true
														selectedEventIndex = 5
												}
												.foregroundColor(titleColors[$0])
												.overlay(Text(eventNumbers[$0] ?? "").font(.footnote).foregroundColor(.blue).offset(x: -16, y: -16))
												.buttonStyle(BorderlessButtonStyle())
												.frame(width: 48, height: 48, alignment: .center)
												.background(RoundedRectangle(cornerRadius: 2)
																				.fill(fillColors[$0])
																				.shadow(color: shadowColors[$0], radius: 2, x: 0, y: 0)
												)
												.sheet(isPresented: $eventPresented) {
														EventView(eventVisible: self.$eventPresented, valueFromParent: self.$selectedEventIndex)
												}
										}
								}
								.frame(width: 336.0, height: 48.0, alignment: .leading)
						}
				}
		}
}
struct EventView: View {
		@Binding var eventVisible: Bool
		@Binding var valueFromParent : Int
		var body: some View {
				VStack {
						Text("This is a sheet.")
						Button("OK") {
								self.eventVisible = false
								print("From parent: \(valueFromParent)")
						}
				}
				.frame(width: 240, height: 180)
		}
}
For now, I arbitrarily set eventPresented to 5, which will be passed to EventView. How can I set $0 to this state value like
eventPresented = $0
Thank you.
Again, I have a vertical stack of horizontal stacks of buttons as follows.
import SwiftUI
struct ContentView: View {
		@State private var eventPresented = Bool()
		@State private var selectedEventIndex = Int()
		@State private var monthSelection = Int()
		
		var body: some View {
				VStack {
						VStack(spacing: 0.0) {
								HStack(spacing: 0.0) {
										ForEach((0...6), id: \.self) {
												index in
												Button(buttonTitles[index] ?? "") {
														eventPresented = true
														selectedEventIndex = index + 1 - self.weekIndex
												}
												.foregroundColor(titleColors[index])
												.overlay(Text(eventNumbers[index] ?? "").font(.footnote).foregroundColor(.blue).offset(x: -16, y: -16))
												.buttonStyle(BorderlessButtonStyle())
												.frame(width: 48, height: 48, alignment: .center)
												.background(RoundedRectangle(cornerRadius: 2)
																				.fill(fillColors[index])
																				.shadow(color: shadowColors[index], radius: 2, x: 0, y: 0)
												)
												.sheet(isPresented: $eventPresented) {
														EventView(eventVisible: self.$eventPresented, dayFromParent: self.$selectedEventIndex, monthFromParent: self.$monthSelection)
												}
										}
								}
								...
								...
								HStack(alignment: .top, spacing: 0.0) {
										ForEach((35...36), id: \.self) {
												index in
												Button(buttonTitles[index] ?? "") {
														eventPresented = true
														selectedEventIndex = index + 1 - self.weekIndex
												}
												.foregroundColor(titleColors[index])
												.overlay(Text(eventNumbers[index] ?? "").font(.footnote).foregroundColor(.blue).offset(x: -16, y: -16))
												.buttonStyle(BorderlessButtonStyle())
												.frame(width: 48, height: 48, alignment: .center)
												.background(RoundedRectangle(cornerRadius: 2)
																				.fill(fillColors[index])
																				.shadow(color: shadowColors[index], radius: 2, x: 0, y: 0)
												)
												.sheet(isPresented: $eventPresented) {
														EventView(eventVisible: self.$eventPresented, dayFromParent: self.$selectedEventIndex, monthFromParent: self.$monthSelection)
												}
										}
								}
								.frame(width: 336.0, height: 48.0, alignment: .leading)
						}
				}
		}
}
And I want to send a few variables to EventView when the user clicks on a button.
struct EventView: View {
		@Binding var eventVisible: Bool
		@Binding var dayFromParent: Int
		@Binding var monthFromParent: Int
		var body: some View {
				VStack {
						Text("Window sheet.")
						Button("OK") {
								self.eventVisible = false
								print("month from parent: \(monthFromParent)")
								print("day from parent: \(dayFromParent)")
						}
				}
				.frame(width: 240, height: 180)
		}
}
If I just want to send two variables to it,
EventView(eventVisible: self.$eventPresented, dayFromParent: self.$selectedEventIndex)
the compiler didn't complain. For the third variable, it says
SwiftUI the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions I know what it means. Some say it could resolve the issue by making the data types of variables clearer. Others say you could use a function to return a variable for a somewhat complex algebra equation. But what can I do in my case? Does anybody have any suggestions?
Thank you
I have a SwiftUI view with a button. I want to open a window sheet from a storyboard. Showing a window sheet isn't a problem. It's just that the application no longer has a menu bar. As soon as I created a storyboard and a view controller (NSViewController), the application stopped showing up properly. Now, if I try to debug it (Command + R), the window won't appear. So I have to click on the Live Preview button on the Canvas. If I do, I can click on the Bring Forward button. Finally, if I click on it, the application window always appears at the bottom-left corner of the desktop without the menu bar. So what's the issue?
Anyway, the following is my code.
// SwiftUI View //
import SwiftUI
struct ContentView: View {
		@State private var sheetPresented = false
		@State private var selectionIndex = 3
		
		var body: some View {
				ZStack {
						VStack {
								Button(action: {
										sheetPresented = true
								}) {
										Text("Show me a sheet")
								}
								.sheet(isPresented: $sheetPresented) {
										SheetViewControllerRepresentation(message: String(selectionIndex))
								}
						}
				}.frame(minWidth: 360, idealWidth: 360, maxWidth: 360, minHeight: 240, idealHeight: 240, maxHeight: 240, alignment: .center)
		}
}
// View controller //
import Cocoa
import SwiftUI
class SheetViewController: NSViewController {
		// MARK: -
		var message = String()
		
		
		// MARK: - IBOutlet
		@IBOutlet weak var messageLabel: NSTextField!
		
		
		// MARK: - Life cycle
		override func viewDidLoad() {
				super.viewDidLoad()
				// Do view setup here.
		}
		
		override func viewWillAppear() {
				super.viewWillAppear()
				
				messageLabel.stringValue = message
		}
		
		override func viewDidAppear() {
				super.viewDidAppear()
				
				view.setFrameSize(CGSize(width: 320, height: 220))
		}
}
struct SheetViewControllerRepresentation: NSViewControllerRepresentable {
		var message = String()
		
		func makeNSViewController(context: NSViewControllerRepresentableContext<SheetViewControllerRepresentation>) -> SheetViewController {
				let mainStoryboard = NSStoryboard(name: "Main", bundle: nil)
				let sheetViewController = mainStoryboard.instantiateController(withIdentifier: "SheetView") as! SheetViewController
				sheetViewController.message = self.message
				return sheetViewController
		}
		
		func updateNSViewController(_ nsViewController: SheetViewController, context: NSViewControllerRepresentableContext<SheetViewControllerRepresentation>) {
		}
}
Thank you.
I have a SwiftUI desktop application. And I need to open a window sheet from a storyboard with a click of a button, which works. But I have a problem.
The opening window sheet is very big. Its size is 1,400 x 300 pixels. (I don't know the exact height.) I don't know where this size comes from. But I need to make it smaller. If I try to do it with the view controller, it doesn't work. How can I control the opening window sheet size?
// SwiftUI View //
import SwiftUI
struct ContentView: View {
		@State private var sheetPresented = false
		@State private var selectionIndex = 3
		
		var body: some View {
				ZStack {
						VStack {
								Button(action: {
										sheetPresented = true
								}) {
										Text("Show me a sheet")
								}
								.sheet(isPresented: $sheetPresented) {
										SheetViewControllerRepresentation(message: String(selectionIndex))
								}
						}
				}.frame(minWidth: 360, idealWidth: 360, maxWidth: 360, minHeight: 240, idealHeight: 240, maxHeight: 240, alignment: .center)
		}
}
// View controller //
import Cocoa
import SwiftUI
class SheetViewController: NSViewController {
		// MARK: -
		var message = String()
				
		// MARK: - IBOutlet
		@IBOutlet weak var messageLabel: NSTextField!
		// MARK: - IBAction		
		@IBAction func closeClicked(_ sender: NSButton) {
				/* closing window */
				self.view.window?.setIsVisible(false)
				self.view.window?.close()
		}
		// MARK: - Life cycle
		override func viewDidLoad() {
				super.viewDidLoad()
				// Do view setup here.
		}
		
		override func viewWillAppear() {
				super.viewWillAppear()
				
				messageLabel.stringValue = message
		}
		
		override func viewDidAppear() {
				super.viewDidAppear()
				
				view.setFrameSize(CGSize(width: 320, height: 220))
		}
}
struct SheetViewControllerRepresentation: NSViewControllerRepresentable {
		var message = String()
		
		func makeNSViewController(context: NSViewControllerRepresentableContext<SheetViewControllerRepresentation>) -> SheetViewController {
				let mainStoryboard = NSStoryboard(name: "Main", bundle: nil)
				let sheetViewController = mainStoryboard.instantiateController(withIdentifier: "SheetView") as! SheetViewController
				sheetViewController.message = self.message
				return sheetViewController
		}
		
		func updateNSViewController(_ nsViewController: SheetViewController, context: NSViewControllerRepresentableContext<SheetViewControllerRepresentation>) {
		}
}
Thank you.